#include <bits/stdc++.h>
#include <assert.h>

using namespace std;

int main()
{
	string x;
	cin >> x;
	for (int i = x.size() - 2; 0 <= i; i--)
		if (x.substr(i, 2) == "ST")
			x.erase(i, 2);
	cout << x.size() << endl;

	return 0;
}
