#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18 * 5;
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string X;
  cin >> X;
  int ans = 0;
  for (int i = 0; i < ((int)X.size()); i++) {
    if (X[i] == 'T')
      ans += 2;
    else
      break;
  }
  int tmp = 0;
  for (int i = 0; i < ((int)X.size()); i++) {
    if (X[X.size() - 1 - i] == 'S')
      tmp += 2;
    else
      break;
  }
  ans = max(ans, tmp);
  cout << ans << "\n";
  return 0;
}
