#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  size_t i;
  bool b = 1;
  unsigned int u = 0;
  while (b) {
    i = s.find("ST");
    if (i == string::npos) {
      b = 0;
    } else {
      s.erase(i, i + 1);
      u = u + 1;
    }
  }
  cout << s.length();
  return 0;
}
