#include <bits/stdc++.h>
using namespace std;
int main(void) {
  string s;
  cin >> s;
  int S = 0, T = 0, sum = 0;
  for (S = s.size() - 1; S >= 0; S--) {
    if (s[S] == 'T') continue;
    for (T = S + 1; T < s.size(); T++) {
      if (s[T] == 'T') {
        sum++;
        break;
      }
    }
  }
  cout << s.size() - (2 * sum) << "\n";
  return 0;
}
