//In the name of God
#include<bits/stdc++.h>

using namespace std;

const int N = 2e5 + 10;
string s;
int n, cnt;

int main(){
	cin >> s;	n = s.size();
	for(auto c : s){
		if(c == 'S')
			cnt++;
		else if(cnt){
			cnt--;
			n -= 2;
		}
	}
	cout << n;
	return 0;
}