#include <bits/stdc++.h>
using namespace std;

int main() {

	string s;
	cin >> s;
	int l = 0, mx = 0;

	for (char c : s) {
		if (c == 'T') l++;
		else l--;
		mx = max(mx, l);
	}

	cout << 2 * mx << endl;

}