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