#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string S;
  cin >> S;
  while (S.find("ST") != string::npos) {
    S.erase(S.begin() + (int)S.find("ST"), S.begin() + (int)S.find("ST") + 1);
  }
  cout << (int)S.size() << endl;
  return 0;
}
