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