#include <bits/stdc++.h>
int main() {
  std::string s;
  std::cin >> s;
  long long count = s.length();
  for (long long i = 0; count != 0 && i < s.length() - 1; ++i) {
    if (s[i] == 'S' && s[i + 1] == 'T') {
      s.erase(s.begin() + i);
      s.erase(s.begin() + i);
      count -= 2;
      i = -1;
    }
  }
  std::cout << count << std::endl;
  return 0;
}
