#include<iostream>
#include<string>
using namespace std;
int main() {
	string s;
	int i, p=0,a=0;
	cin >> s;
	for (auto x : s) {
		if (x == 'S')
			p++;
		if (x == 'T') {
			if (p > 0)
				p--;
			else
				a++;
		}
	}
	cout << a*2 << endl;
}