#include<iostream>
using namespace std;
int main()
{
	string s;
	cin >> s;
	string::sizetype index i;
	bool b = 1;
	unsigned int u = 0;
	while(b){
		i = s.find("ST");
		if(index == string::npos){
			b = 0;
		} else {
			s.erase(i);
			s.erase(i);
			u = u + 1;
		}
	}
	cout << s.length();
	return 0;
}