#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e10;
const long long ZERO = 0;
signed main() {
  string S;
  cin >> S;
  long long A;
  long long B;
  for (long long i = 0; i < S.size(); i++) {
    if (S.at(i) == 'S') {
      A = i;
      break;
    }
  }
  for (long long i = S.size() - 1; i >= 0; i--) {
    if (S.at(i) == 'T') {
      B = S.size() - 1 - i;
      break;
    }
  }
  A = S.size() / 2 - A;
  B = S.size() / 2 - B;
  cout << S.size() - min(A, B) * 2 << endl;
}
