#include <bits/stdc++.h>
std::vector<char> st(std::vector<char> X, long long n) {
  bool s_flag = false;
  int t_count = 0;
  auto ite = X.begin();
  while (ite != X.end()) {
    if (*ite == 'T') t_count++;
    if (*ite == 'S') {
      s_flag = true;
      ite++;
    } else if (*ite == 'T' && s_flag == true) {
      X.erase(ite - 1, ite + 1);
      n = n - 1;
      t_count = 0;
      if (n == 0 || X.size() == 0) {
        break;
      } else {
        ite = X.begin();
        s_flag = false;
      }
    } else {
      ite++;
    }
    if (t_count == X.size() / 2) {
      break;
    }
  }
  return X;
}
int main(void) {
  std::vector<char> X;
  char c;
  long long n = 10 * 10000;
  while (std::cin >> c) {
    X.push_back(c);
  }
  std::cout << st(X, n).size() << std::endl;
  return 0;
}
