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