#include <bits/stdc++.h>
using namespace std;
string S;
int ans() {
  string::iterator it = S.begin(), it2 = S.end();
  while (it != it2) {
    if (*it == 'S' && *(it + 1) == 'T') {
      S.erase(it, it + 2);
      it = S.begin();
      it2 = S.end();
    }
  }
  return S.size();
}
int main() {
  cin >> S;
  int res = ans();
  cout << res << endl;
  return 0;
}
