#include <cstdio>

const int MAXN = 2E5 + 10;

char s[MAXN];
int que[MAXN], tail;

int main(){
	scanf("%s", s);
	for (int i = 0; s[i]; ++i)
		if (s[i] == 'T' && tail >= 0 && que[tail] == 'S')
			--tail;
		else
			que[++tail] = s[i];
	printf("%d\n", tail);
	return 0;
}
