#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int jdg, flag = 0;
  while (!flag) {
    int len = s.size();
    jdg = s.find("ST");
    if (jdg < 0)
      flag = 1;
    else {
      s.erase(jdg, 2);
    }
    if (len == s.size()) break;
  }
  cout << s.size() << endl;
  return 0;
}
