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