#include <bits/stdc++.h>
using namespace std;

int main()
{
    string s; cin>>s;
    stack<char> a;
    for(auto& c: s)
        c=='T' && a.size() && a.top()=='S' ?  a.pop() : a.push(c);
    cout<<a.size()<<endl;
}