#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int ans = s.length();
  bool hatu = true;
  for (int i = 0; i < s.length() - 1; i++) {
    if (s[i] == 'S') {
      for (int j = i + 1; j < s.length(); j++) {
        if (s[j] == 'T') {
          ans -= 2;
          s[j] = '*';
          break;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}
