#include <bits/stdc++.h>
using namespace std;
int main(void) {
  string X;
  cin >> X;
  int ans = X.length();
  int T_last = ans - 1;
  for (int i = T_last; i >= 0; --i) {
    if (X[i] == 'T') break;
    T_last--;
  }
  T_last++;
  int S_cnt = 0;
  int T_cnt = 0;
  for (int i = (0); i < (T_last); ++i) {
    if (X[i] == 'S')
      S_cnt++;
    else if (X[i] == 'T')
      T_cnt++;
  }
  ans -= min(S_cnt, T_cnt) * 2;
  cout << ans << endl;
  return 0;
}
