#include <bits/stdc++.h>
using namespace std;
signed main() {
  string s;
  cin >> s;
  long long sco = 0, tco = 0;
  long long ans = s.size();
  for (long long i = 0; i < s.size(); i++) {
    if (s[i] == 'S') {
      sco++;
    } else {
      tco++;
      if (i + 1 == s.size() || s[i + 1] == 'S') {
        ans -= min(sco, tco) * 2;
        sco -= min(sco, tco);
        tco -= min(sco, tco);
      }
    }
  }
  cout << ans << endl;
}
