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