#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f2f1f0f;
const long long LINF = 1ll * INF * INF;
string S;
int main() {
  cin >> S;
  while (true) {
    bool change = false;
    for (int i = 0; i + 1 < ((int)(S).size()); i++) {
      if (S[i] == 'S' && S[i + 1] == 'T') {
        change = true;
        S = S.substr(0, i) + S.substr(i + 2, ((int)(S).size()) - i - 2);
        break;
      }
    }
    if (!change) break;
  }
  printf("%d\n", ((int)(S).size()));
  return 0;
}
