#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  auto last = s.find_last_of('T');
  int count = 0;
  for (string::size_type i = 0; i < last; ++i) {
    if (s[i] == 'S') ++count;
  }
  cout << (s.size() - count * 2) << endl;
  return 0;
}
