#include <bits/stdc++.h>
using namespace std;
int main(int argc, char** argv) {
  string s;
  cin >> s;
  int n = s.size();
  int j = n;
  for (j;; j--) {
    if (s[j] == 'T') break;
  }
  int k = 0;
  for (k;; k++) {
    if (s[k] == 'S') break;
  }
  int tnum;
  int snum;
  for (int i = k; i <= j; i++) {
    if (s[i] == 'S') snum++;
    if (s[i] == 'T') tnum++;
  }
  cout << k + (n - j) + abs(snum - tnum) - 1;
  return 0;
}
