#include <bits/stdc++.h>

using namespace std;
const int N = 200010;
int _w;

int ct, cs;
char s[N];

int main() {
	cin >> s;
	for( char *p = s; *p; ++p )
		if( *p == 'T' ) {
			if( cs ) --cs;
			else ++ct;
		} else {
			++cs;
		}
	cout << ct+cs << endl;
	return 0;
}
