#include<iostream>
#include<cstdio>
#include<cstring>
#include<stack>
using namespace std;
stack<char>q;
int main(){
	string s;
	cin>>s;
	int len=s.size() ;
	for(int i=0;i<len;i++){
		if(s[i]=='S')q.push('S');
		else{
			if(q.size()==0)q.push('T');
			else{
				char c=q.top();
				if(c=='S')q.pop();
				SSelse q.push('T');
			}
			
		}
	}
	cout<<q.size()<<endl;
} 