#include<bits/stdc++.h>
using namespace std;
string s;
int main()
{
	cin>>s;
	int now=0;
	while (now<s.size()) {
		if (s[now]=='S'&&now+1<s.size()&&s[now+1]=='T') {
			s.erase(now,2);
			if (now>0) now--;
		}
		else now++;
	}
	printf("%d\n",s.size());
	return 0;
} 