#include<bits/stdc++.h>
using namespace std;
const int maxn=200010;
char sk[maxn],s[maxn];
int main() {
	scanf("%s",s+1);
	int n=strlen(s+1),top=0;
	for(int i=1;i<=n;i++) {
		sk[++top]=s[i];
		if(top>1&&sk[top]=='T'&&sk[top-1]=='S')top-=2;
	}
	printf("%d\n",top);
	return 0;
}