#include <bits/stdc++.h>
using namespace std;
int main() {
  string x;
  cin >> x;
  int len = x.length();
  int cnt_t = 0;
  for (int i = 0; i < len; i++) {
    if (x[i] == 'S') {
      break;
    }
    ++cnt_t;
  }
  int cnt_s = 0;
  for (int i = len - 1; i >= 0; i--) {
    if (x[i] == 'T') {
      break;
    }
    ++cnt_s;
  }
  cout << 2 * max(cnt_t, cnt_s) << endl;
}
