#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
	string s; cin >> s;
	ll S = 0, T = 0;
	ll ans = 0;
	for(ll i = 0; i < s.size(); ++i){
		(s[i] == 'S' ? S : T)++;
		if(S < T){
			ans++;
			T--;
		}
	}
	cout << ans * 2 << endl;
	return 0;
}