#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  string str;
  cin >> str;
  int i = 0;
  for (auto it = str.begin(); it != str.end(); it++) {
    if (*it == 'S' && *(it + 1) == 'T') {
      it++;
      continue;
    }
    i++;
  }
  cout << i << endl;
  return 0;
}
