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