#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int s_num = 0, del_num = 0, prev = 'T';
  for (char ch : s) {
    if (ch == 'T') {
      if (s_num > 0) {
        s_num--;
        del_num++;
      }
    } else {
      if (prev == 'T') s_num = 0;
      s_num++;
    }
    prev = ch;
  }
  cout << s.size() - 2 * del_num << endl;
  return 0;
}
