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