#include<iostream>
#include<cstdio>
#include<string>
//#include<vector>
//#include<stack>

using namespace std;

int main() {
	string str; scanf("%s", str);
	//stack<int, vector<int>> S;
	int sz = str.size(); int len = 0, p = 0;
	for (int i = 0; i < sz; i++) {
		if (str[i] == 'S') len++;
		else if (len > 0) { len--; p++; }
	}
	printf("%d", sz - 2 * p);
}