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