#include <bits/stdc++.h>
using namespace std;
const long long MOD = pow(10, 9) + 7;
const long long LLINF = pow(2, 61) - 1;
const int INF = pow(2, 30) - 1;
int main() {
  string X;
  cin >> X;
  int l = X.length();
  int n1 = 0, n2 = 0;
  while (X[n1] == 'T') n1++;
  while (X[l - 1 - n2] == 'S') n2++;
  int result = max(n1, n2) * 2;
  cout << result << endl;
  return 0;
}
