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