#include<iostream>
#include<string>
using namespace std;
string ch;
int cnts,cnt;
int main(){
	cin>>ch;
	int i=0;
	for(int i=0;i<ch.length();i++){
		if(ch[i]=='S'){
			cnts++;
		}
		if(cnts&&ch[i]=='T'){
			cnts--;
			cnt+=2;
		}
	}
	cout<<ch.length()-cnt<<endl;
	return 0;
}