#include<iostream>
#include<string>

using namespace std;

int main()
{
	string s;
	cin >> s;

	int cs=0,ct=0,ans=0;

	for(int i=1;i<=s.size();i++)
	{
		if(s[i-1]=='S')
			cs++;
		else
		{
			if(ct==cs)ans++;
			else ct++;
		}
	}
	ans*=2;
	cout << ans << endl;
}