#include <bits/stdc++.h>
using namespace std;
signed main() {
  string s;
  cin >> s;
  long long n = s.size();
  long long res = 1;
  while (res != 0) {
    res = 0;
    for (long long i = 0; i < n - 1; i++) {
      if (s.substr(i, 2) == "ST") {
        s = s.substr(0, i) + s.substr(i + 2, n - i - 2);
        n -= 2;
        res += 1;
      }
    }
  }
  cout << n << endl;
}
