#include <bits/stdc++.h>
using namespace std;
long long n;
char q[111111];
string s;
int main() {
  cin >> s;
  for (long long i = 0; i < s.size(); i++) {
    if (s[i] == 'T' && n > 0 && q[n] == 'S')
      n--;
    else
      q[++n] = s[i];
  }
  cout << n;
}
