#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int l, r;
  l = r = 0;
  for (int i = 0;; i++) {
    if (s[i] == 'T')
      l++;
    else
      break;
  }
  int siz = s.size();
  for (int i = siz - 1;; i--) {
    if (s[i] == 'S')
      r++;
    else
      break;
  }
  cout << 2 * max(r, l);
}
