#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  for (auto it = s.begin(); it != s.end(); it++) {
    if (*it == 'S' && *(it + 1) == 'T') {
      s.erase(it);
      s.erase(it);
      it = it - 1;
    }
  }
  cout << s.size();
  return 0;
}
