#include <bits/stdc++.h>
using namespace std;
const long long zero = 0;
const long long INF = 3000000000000000000;
const int inINF = 1000000000;
const long long MOD = 1000000007;
const long long MOD2 = 998244353;
void Yes() { printf("Yes\n"); }
void No() { printf("No\n"); }
void YES() { printf("YES\n"); }
void NO() { printf("NO\n"); }
int main() {
  string X;
  cin >> X;
  long long N = X.length();
  long long a, b;
  a = 0;
  b = 0;
  for (long long i = 0; i < N; i++) {
    if (X[i] == 'T') {
      a++;
    } else {
      break;
    }
  }
  for (long long i = N - 1; i >= 0; i--) {
    if (X[i] == 'S') {
      b++;
    } else {
      break;
    }
  }
  printf("%lld\n", 2 * max(a, b));
}
