#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, src = "ST";
  while (cin >> s) {
    int ind = s.find(src);
    while (ind != string::npos) {
      s.erase(ind, 2);
      ind = s.find(src);
    }
    printf("%d\n", s.length());
  }
  return 0;
}
