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