#include <bits/stdc++.h>
using namespace std;
int main() {
  string str;
  cin >> str;
  int flags = 0;
  int ans = 0;
  for (int i = 0; i < (int)(str.size()); i++) {
    if (flags == 0 && str[i] == 'S') {
      flags = 1;
    }
    if (flags == 0 && str[i] == 'T') {
      ans++;
    }
    if (flags == 1 && str[i] == 'T') {
      flags = 0;
    }
  }
  cout << ans * 2 << endl;
  return 0;
}
