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