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