#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;
template <typename T>
bool chmin(T& x, T y) {
  if (x > y) {
    x = y;
    return true;
  }
  return false;
}
template <typename T>
bool chmax(T& x, T y) {
  if (x < y) {
    x = y;
    return true;
  }
  return false;
}
signed main() {
  string s;
  cin >> s;
  int n = s.size();
  int i;
  for (i = 0; i < n; ++i) {
    if (s[i] == 'S') break;
  }
  int j;
  for (j = n - 1; j >= 0; --j) {
    if (s[j] == 'T') break;
  }
  cout << max(i, (n - j - 1)) * 2 << endl;
}
