#include <iostream>
#include <string>
using namespace std;



int main(){
	string s;
	cin>>s;
	for(auto it=s.begin();it!=s.end();it++){
		if(*it=='S'&&*(it+1)=='T'){
			s.erase(it);
			s.erase(it);
			it=it-2;
		}
	}
	cout<<s.size();
	
	return 0;
} 