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