#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline T gcd(T a, T b) {
  T c;
  while (b != 0) {
    c = a % b;
    a = b;
    b = c;
  }
  return a;
}
template <class T>
inline T lcm(T a, T b) {
  return a * b / gcd(a, b);
}
const int INF = 1e9;
const double eps = 0.0000000001;
int main() {
  string x;
  cin >> x;
  int cnt = 0;
  for (int i = 0; i < (x.size()); i++) {
    if (x[i] == 'S') {
      cnt = i;
      break;
    }
  }
  reverse(x.begin(), x.end());
  for (int i = 0; i < (x.size()); i++) {
    if (x[i] == 'T') {
      chmax(cnt, i);
      break;
    }
  }
  cout << cnt * 2 << endl;
}
