#include <bits/stdc++.h>
using namespace std;
string s;
int main() {
  cin.sync_with_stdio(false);
  cin >> s;
  int tcnt = 0, scnt = 0;
  for (int i = (int)(0); i < (int)(s.length()); i++) {
    if (s[i] == 'T')
      tcnt++;
    else
      scnt++;
    if (tcnt == s.length() / 2) break;
  }
  cout << s.length() - (scnt * 2) << endl;
  return 0;
}
