#include <bits/stdc++.h>
using namespace std;
int main() {
  string X;
  cin >> X;
  int remcnt = 0;
  bool flg = false;
  int scnt = 0;
  int tcnt = 0;
  bool pre_is_T = false;
  for (int i = 0; i < (int)(X.size()); i++) {
    if (X.at(i) == 'S') {
      if (pre_is_T) {
        remcnt += 2 * min(scnt, tcnt);
        scnt = 0;
        tcnt = 0;
        pre_is_T = false;
      }
      scnt++;
    } else {
      tcnt++;
      pre_is_T = true;
    }
  }
  remcnt += 2 * min(scnt, tcnt);
  cout << X.size() - remcnt << endl;
  return 0;
}
