#include <bits/stdc++.h>
using namespace std;
int main() {
  string str;
  cin >> str;
  int index;
  while (true) {
    index = str.find("ST");
    if (index == -1) break;
    str.erase(index, 2);
  }
  cout << str.size() << endl;
  return 0;
}
