#include <iostream>
using namespace std;

int main() {
	string X;
	cin >> X;
	int S = 0, T = 0;
	for (char c : X) {
		if (c == 'S') S++;
		else {
			if (S > 0) S--;
			else T++;
		}
	}
	cout << S + T << endl;
}
