#include <iostream>
#include <string>
using namespace std;

int main() {
	string s;
	cin >> s;
	int S = 0, T = 0, count = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'S') S++;
		else T++;
		if (S < T) count += 2, T--;
	}
	cout << count << endl;
}