#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  vector<char> stack;
  for (int i = 0; i < S.size(); i++) {
    if (S[i] == 'S')
      stack.push_back(S[i]);
    else {
      if (stack.empty())
        stack.push_back(S[i]);
      else if (stack.back() == 'T')
        stack.pop_back();
    }
  }
  cout << stack.size() << endl;
  return 0;
}
