#include <iostream>
using namespace std;
int main() {
    string x; cin >> x;
    int ans = x.size(), s = 0;
    for (char c : x) {
        if (c == 'S') s++;
        else if (s > 0) { s--; ans -= 2; }
    }
    cout << ans << endl;
}
