#include <bits/stdc++.h>
int main() {
  std::stack<char> strStack;
  std::string str;
  std::cin >> str;
  std::string::iterator itr = str.begin();
  while (itr != str.end()) {
    if (strStack.empty() || (strStack.top() == 'T')) {
      strStack.push(*itr);
    } else if (!strStack.empty() || (strStack.top() == 'S')) {
      if (*itr == 'T') {
        strStack.pop();
      }
    }
    itr++;
  }
  std::cout << strStack.size() << std::endl;
  return 0;
}
