#include <bits/stdc++.h>
using namespace std;
int main() {
  string X;
  cin >> X;
  bool conti = true;
  while (X.size() > 0 && conti == true) {
    conti = false;
    int pos;
    for (int i = 0; i < X.size() - 1; i++) {
      if (X[i] == 'S' && X[i + 1] == 'T') {
        conti = true;
        pos = i;
        break;
      }
    }
    if (conti == true) {
      X = ((pos == 0) ? "" : X.substr(0, pos)) +
          ((pos == X.size() - 2) ? "" : X.substr(pos + 2));
    }
  }
  cout << X.size() << endl;
}
