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