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