#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int n = s.size();
  int sn = 0, tn = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'S') break;
    tn++;
  }
  for (int i = n - 1; i >= 0; i--) {
    if (s[i] == 'T') break;
    sn++;
  }
  int a = tn - sn;
  if (a < 0) a *= -1;
  cout << tn + sn + a << endl;
  return 0;
}
