#include <bits/stdc++.h>

using namespace std;

int main () {
  string s;
  cin >> s;
 
  int n = (int)s.size();
  stack<char> st;
  for (int i = 0; i < n; ++i) {
    if (s[i] == "S") st.push(s[i]);
    else {
      if (st.top() == "S") st.pop();
      else st.push(s[i]);
    }
  }
  cout << st.size() << endl;
  return 0;
}
