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

int main() {
	string s;
	for (char c; cin >> c; ) {
		s.push_back(c);
		if (s.size() >= 2 && s.back() == 'T' && s.rbegin()[1] == 'S') {
			s.pop_back();
			s.pop_back();
		}
	}
	cout << s.size();
    return 0;
}