#include <bits/stdc++.h>
using namespace std;
string X;
int main() {
  cin >> X;
  int ans = X.size(), s = 0;
  for (int i = 0; i < X.size();) {
    if (X[i] == 'S')
      s++;
    else {
      if (s) {
        s--;
        ans -= 2;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
