#include <bits/stdc++.h>
using namespace std;
int main() {
  stack<char> st;
  string str;
  cin >> str;
  int strlength = str.size();
  for (int i = 1; i < strlength; ++i) {
    if (str[i - 1] == 'S' && str[i] == 'T') {
      str.erase(str.begin() + i);
      str.erase(str.begin() + i - 1);
      i = i - 2;
      strlength = strlength - 2;
    }
  }
  for (int i = 0; i < str.length(); i++) {
    st.push(str[i]);
  }
  cout << st.size() << endl;
}
