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