#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
int main() {
  string X;
  cin >> X;
  int N = X.size();
  int cnt1 = 0;
  int cnt2 = 0;
  for (int i = N - 1; i >= 0; i--) {
    if (X[i] == 'S')
      cnt1++;
    else
      break;
  }
  for (int i = (int)(0); i < (int)(N); i++) {
    if (X[i] == 'T')
      cnt2++;
    else
      break;
  }
  cout << max(cnt1, cnt2) * 2 << endl;
}
