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