#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	string s;
	cin>>s;
	int ans=0,a=0;
	for(int i=0;i<s.size();i++){
		if(s[i]=='S')a++;
		else a--;
		if(a<0)ans++,a++;
	}cout<<2*ans<<endl;
	return 0;
}
