#include <bits/stdc++.h>
#define N 200006
using namespace std;
int n,m;char c[N],a[N];
int main()
{
	scanf("%s",c+1);n=strlen(c+1);
	for(int i=1;i<=n;i++){
		if(m&&a[m]=='S'&&c[i]=='T')m--;
		else a[++m]=c[i];
	}
	printf("%d\n",m);
}