#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
const int MOD = 1000000007;
const double eps = 1e-9;
int main(int argc, char *argv[]) {
  string X;
  cin >> X;
  int s_pos = 0, s_cnt = 0;
  int t_pos = 0, t_cnt = 0;
  for (int i = 0; i < (int)X.size(); ++i) {
    if (X[i] == 'S') {
      if (s_pos == 0) s_pos = i;
      s_cnt++;
    } else {
      t_pos = i, t_cnt++;
    }
  }
  s_cnt -= (int)X.size() - t_pos - 1;
  t_cnt -= s_pos - 1;
  int ans = X.size() - 2 * min(s_cnt, t_cnt);
  cout << ans << endl;
  return 0;
}
