#include <iostream>
#include <string>

using namespace std;

int main(){
    string str;
    cin >> str;
    int strlength = str.size();
    for (int i = 1; i < strlength; ++i)
    {
        if(str[i-1] == 'S' && str[i] == 'T'){
            str.erase(str.begin() + i);
            str.erase(str.begin() + i - 1);
            i = i-2;
            strlength = strlength - 2;
        }
    }
    cout << str.size() << endl;
}