#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
const int INF = 1000000007;
int main() {
  string s;
  cin >> s;
  deque<char> st;
  st.push_back(s[0]);
  for (int i = 1; i < s.size(); i++) {
    char now = s[i], mae = st.back();
    if (mae == 'S') {
      if (now == 'T')
        st.pop_back();
      else
        st.push_back('S');
    } else {
      st.push_back(now);
    }
  }
  string ans;
  cout << st.size() << endl;
  return 0;
}
