#include<bits/stdc++.h>
using namespace std;
int sum,sum1;
int main() {
	string s;
	cin>>s;
	for(int i=0; i<s.size(); i++) {
		if(s[i]=='S') {
			sum++;
		}
		if(sum>0&&s[i]=='T') {
			sum1+=2;
			sum--;
		}
	}
	cout<<s.size()-sum1<<endl;
}