#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int ind;
  while (true) {
    int ind = -1;
    for (int i = 0; i + 1 < (int)s.length(); ++i)
      if (s.substr(i, 2) == "ST") {
        ind = i;
        break;
      }
    if (ind < 0) break;
    s.erase(ind, 2);
  }
  cout << s.length() << "\n";
  return 0;
}
