#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 100005;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int t = 0;
  for (int i = 0; i < (int)((int)(s).size()); ++i) {
    if (s[i] != 'T') {
      break;
    }
    t++;
  }
  reverse((s).begin(), (s).end());
  int ss = 0;
  for (int i = 0; i < (int)((int)(s).size()); ++i) {
    if (s[i] == 'S') {
      break;
    }
    ss++;
  }
  cout << 2 * max(ss, t) << endl;
  return 0;
}
