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

int main()
{
    int T;
    string p1;
    cin>>p1;
    while(p1.find("ST")!=-1)
        {
            n=p1.find("ST");
            p1.erase(n,2);
        }
        cout<<p1.length()<<endl;
}
