#include <bits/stdc++.h>
using namespace std;
signed main(void) {
  long long t, s;
  string x;
  cin >> x;
  for (long long i = 0; i < x.length(); i++) {
    if (x[i] == 'S') {
      s++;
    } else {
      if (s)
        s--;
      else
        t++;
    }
  }
  cout << s + t << "\r\n";
}
