#include <bits/stdc++.h>
constexpr int MOD = 1000000000 + 7;
constexpr int INF = 2000000000;
using namespace std;
using LL = long long;
int main() {
  string s;
  cin >> s;
  stack<char> st;
  st.push('T');
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'S')
      st.push('S');
    else if (st.top() == 'T')
      st.push('S');
    else
      st.pop();
  }
  cout << (st.size() - 1) * 2 << endl;
}
