#include <bits/stdc++.h>
using namespace std;
int main() {
  string X;
  cin >> X;
  int N = X.size();
  int S, T;
  S = T = 0;
  for (int i = 0; i < N; ++i) {
    if (X[i] == 'S')
      ++S;
    else
      ++T;
  }
  int ans = 0;
  int pos = N - 1;
  while (X[pos] != 'T') {
    ++ans;
    --S;
    --pos;
  }
  ans += abs(S - T);
  cout << ans << endl;
  return 0;
}
