# include <iostream>
# include <fstream>
# include <cstdio>
# include <cstdlib>
# include <vector>
# include <algorithm>
# include <stack>
using namespace std;
stack<char>ch;
int main () {
	string s;
	int ans = 0;
	int n = 1010000;
	cin>>s;
	int sz = s.size();
/*	for(int i=0;i<sz;i++){
		if(s[i]=='S'){
		  ch.push(s[i]);
		}
		else if(s[i]=='T'){
			if(!ch.empty()){
				if(ch.top()=='S'){
					ch.pop();
					ans+=2;
				}
					
			}
		}
	}*/
	for(int i=0;i<sz;i++){
		if(s[i]=='S'){
			if(s[i+1]=='T'){
				ans+=2;
				i+=2;
			}
		}
	}
	cout<<sz-ans;
  
	
	return 0;
}