#include <iostream>
#include <string>
using namespace std;

int main() {
	string X;
	cin >> X;
	int tmp1 = 0, tmp2 = 0;
	for (char& i : X) {
		if (i == 'S') ++tmp1;
		else {
			if (tmp1 == 0) ++tmp2;
			else --tmp1;
		}
	}
	cout << tmp1 + tmp2;
}