#include <bits/stdc++.h>
using namespace std;
int main() {
  int scnt = 0, tcnt = 0, tmp = 0;
  string S;
  cin >> S;
  for (char c : S) {
    if (c == 'S') tmp++;
    if (c == 'T') {
      tcnt++;
      scnt += tmp;
      tmp = 0;
    }
  }
  cout << S.size() - 2 * min(scnt, tcnt) << endl;
}
