#include <bits/stdc++.h>
using namespace std;
int solve(string s) {
  stack<char> st;
  char bg = s[0];
  st.push(bg);
  for (int i = 1; i != s.length(); i++) {
    char temp = st.top();
    if (temp == 'S' && s[i] == 'T')
      st.pop();
    else
      st.push(s[i]);
  }
  return st.size();
}
int main() {
  string s;
  while (!(cin >> s).eof()) {
    int ans = solve(s);
    cout << ans << endl;
  }
  return 0;
}
