#include <bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	int count=0;
	int i;
	int ans=s.size();
	for( i=(s.size()-1);i>=0;i--){
		if(s[i]=='T') count++;
		if(s[i]=='S' && count>0) {count--;ans-=2;}
	}
	cout<<ans;
}