#include <cstdio>
#include <cstring>
const int N = 2e5 + 5;
char s[N];
int len, pre, cnt;
int main() {
	scanf("%s", s + 1), len = strlen(s + 1);
	for (int i = 1; s[i]; ++i) 
		if (s[i] == 'S') ++pre;
		else if (pre) --pre, ++cnt;
		
	printf("%d\n", len - cnt * 2);
	return 0;
}