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