#include <iostream>
#include <stack>
#include <string>
using namespace std;

int main (){
	string str;
	stack<char> st;
	int cnt = 0;
	cin>>str;
	for (int i = str.size() - 1; i >= 0; i--)
	{
		if (str[i] == 'T'&& str[i-1] == 'S'){
			st.push(str[i]);//cnt++;
			st.push(str[i-1]);
			cnt++;
		}
	}
	
	cout<<str.size()-cnt-1<<endl;
	return 0;
}