#include <bits/stdc++.h>
int main() {
  std::ios::sync_with_stdio(false);
  std::string str;
  std::string now;
  std::cin >> str;
  for (int i = 0; i < str.length(); i++) {
    if (str[i] == 'T' && now.back() == 'S')
      now.pop_back();
    else
      now.push_back(str[i]);
  }
  std::cout << now.length() << std::endl;
}
