#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  string s;
  cin >> s;
  stack<char> q;
  q.push(s[0]);
  long long i = 1;
  for (long long i = 1; i < s.length(); i++) {
    if (s[i] == 'T' && q.top() == 'S') {
      q.pop();
    } else {
      q.push(s[i]);
    }
  }
  cout << q.size() << endl;
}
