#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  int ans = 0;
  int t_count = 0;
  int s_count = 0;
  cin >> s;
  for (int i = s.size() - 1; i >= 0; i--) {
    if (s[i] == 'T') {
      s_count = 0;
      t_count++;
    } else {
      s_count++;
      if (s_count <= t_count) {
        ans++;
      }
    }
  }
  cout << s.size() - ans * 2 << endl;
}
