#include <bits/stdc++.h>
using namespace std;
int main() {
  string str;
  cin >> str;
  while (str.find("ST") != std::string::npos) {
    int p = str.find("ST");
    str.erase(p, 2);
  }
  cout << str.size() << endl;
  return (0);
}
