#include<iostream>
#include<string>
using namespace std;
int main(){
	string s;
	cin>>s;
	int l=s.length();
	int sum=0,ans=0;
	for(int i=0;i<l;i++)
		if(s[i]=='S')
			sum++;
		else if(sum>0)sum--;
			else ans++;
	ans+=sum;
	cout<<ans;
	return 0;
} 