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