#include <bits/stdc++.h>
int main(void) {
  std::string X;
  std::cin >> X;
  int count = 0;
  while (X.find("ST", 0) != std::string::npos) {
    X.erase(X.find("ST", 0), 2);
    count++;
    if (count == 100000) {
      break;
    }
  }
  std::cout << X.length() << std::endl;
  return (0);
}
