#include <iostream>
#include <string>
#include <stdio.h>
#include <string.h>

using namespace std;

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