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