#include <bits/stdc++.h>
using namespace std;
int main(void) {
  string x;
  cin >> x;
  int i = 0;
  for (i; i < x.size(); i++) {
    if (x[i] == 'S' && x[i + 1] == 'T') {
      x.erase(x.begin() + i, x.begin() + i + 2);
      i = -1;
    }
  }
  cout << x.size() << endl;
  return 0;
}
