#include <bits/stdc++.h>
const int mod = 1000 * 1000 * 1000 + 7;
using namespace std;
int main()
{
	string s;
	cin >> s;
	vector<int> v;
	for(auto x : s)
	{
		if(x == 'S')
			v.PB(x);
		else if(x == 'T' && v.size() && v.back() == 'S')
			v.pop_back();
		else
			v.PB(x);
	}
	cout << v.size() << endl;
}