#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9 + 7;
const long long LINF = 1e18;
using namespace std;
void CINT() {}
template <class Head, class... Tail>
void CINT(Head&& head, Tail&&... tail) {
  cin >> head;
  CINT(move(tail)...);
}
int main() {
  string s;
  CINT(s);
  vector<int> v;
  int n = s.size();
  for (int i = 0; i < (s.size()); ++i) v.push_back(s[i] == 'T');
  int be, en;
  for (int i = 0; i < (n); ++i)
    if (v[i] == 0) {
      be = i;
      break;
    }
  for (int i = n - 1; i >= 0; i--)
    if (v[i] == 1) {
      en = n - i - 1;
      break;
    }
  cout << (max(be, en) * 2) << endl;
  return 0;
}
