#include <iostream>
#include <string>
using namespace std;
 
int main() {
	int t = 0,s = 0;
	string ss;
	cin >> ss;
	for(int i = 0;i < ss.size();i++){
		if(ss[i] == 'S'){
			s++;
		}
		if(ss[i] == 'T'){
			if(s > 0) s--;
			else t++;
		}
	}
	cout << s + t << endl;
	return 0;
}