#include<bits/stdc++.h>

using namespace std;

string s;
vector <char> q;

int main()
{
	cin >> s;
	q.push_back(s[0]);
	for(int i = 1 ; i < s.size() ; i++)
	{
		if(q[q.size() - 1] == 'S' && s[i] == 'T')
			q.pop_back();
		else
			q.push_back(s[i]);
	}
	cout << q.size();
}
