#include<bits/stdc++.h>
using namespace std;
char s[200000];
stack<char>ha;
int main(){
	scanf("%s",s+1);
	int len=strlen(s+1);
	for(int i=1;i<=len;++i) {
		if(ha.size()&&ha.top()=='S'&&s[i]=='T') ha.pop();
		else ha.push(s[i]);
	}
	printf("%d",ha.size());
}