#include <iostream>
using namespace std;

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