#include <bits/stdc++.h>
using namespace std;
int main() {
  string x;
  cin >> x;
  while (true) {
    if (x.find("ST") == -1) {
      break;
    }
    for (int m = 0; m < x.length(); m++) {
      if (x[m] == 'S' && x[m + 1] == 'T') {
        x.erase(m, 2);
      }
    }
  }
  cout << x.size();
}
