#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  bool check = true;
  while (1) {
    check = true;
    for (int i = 1; i < S.size(); i++) {
      if (S[i - 1] == 'S' && S[i] == 'T') {
        S.erase(i - 1, 2);
        check = false;
      }
    }
    if (check) break;
  }
  cout << S.size() << endl;
}
