#include<bits/stdc++.h>
using namespace std;

const int N=2e5+5;
char s[N],st[N];

int main()
{
	//freopen("1.in","r",stdin);
	scanf("%s",s+1);
	int top=0;
	for(char *i=s+1;*i;++i)
	{
		if(st[top]=='S'&&*i=='T')--top;
		else st[++top]=*i;
	}
	printf("%d\n",top);
}