#include<iostream>
#include<vector>
using namespace std;
int main()
{
	string s;
	vector<char> t;
	int ans=0;
	cin>>s;
	for(int i=0;i<s.size();i++)
		if(t.size()&&t.back()=='S'&&s[i]=='T')ans+=2,t.pop_back();
		else t.push_back(s[i]);
	cout<<s.size()-ans<<endl;
}
