#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  while (true) {
    bool erased = false;
    int len = s.length();
    for (int i = 0; i < len - 1; i++) {
      if (s[i] == 'S' && s[i + 1] == 'T') {
        erased = true;
        s.erase(i, 2);
        i--;
        len -= 2;
      }
    }
    if (!erased) {
      break;
    }
  }
  cout << s.length() << "\n";
  return 0;
}
