#include <bits/stdc++.h>
using namespace std;
int main() {
  string x;
  int a;
  int start = 0;
  int end = 0;
  a = x.length();
  for (int i = 0; i < a; i++) {
    if (x[i] == 'T') {
      start++;
    } else {
      break;
    }
  }
  for (int i = (a - 1); i >= 0; i--) {
    if (x[i] == 'S') {
      end++;
    } else {
      break;
    }
  }
  cout << a - start - end << endl;
}
