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

int main()
{
    string x; cin>>x;
    stack<char> s;

    for(e: x) {
        if (e=='T' and s.size() and s.top()=='S')
            s.pop();
        else
            s.push(e);
    }
    cout<<s.size()<<endl;
}
#include <iostream>
#include <string>
#include <stack>
using namespace std;

int main()
{
    string x; cin>>x;
    stack<char> s;

    for(e: x) {
        if (e=='T' and s.size() and s.top()=='S')
            s.pop();
        else
            s.push(e);
    }
    cout<<s.size()<<endl;
}
