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