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