#include <bits/stdc++.h>
using namespace std;
int main() {
  string X;
  cin >> X;
  int S = 0, T = 0, delc = 0;
  for (int x = 0; x < X.size(); x++) {
    if (X[x] == 'S') {
      if (T == 0) {
        S++;
      } else {
        delc += min(S, T) * 2;
        S = 1;
        T = 0;
      }
    } else {
      if (S > 0 && S > T) {
        T++;
      }
      if (S == T) {
        delc += S * 2;
        S = 0;
        T = 0;
      }
    }
  }
  cout << X.size() - delc << endl;
  return 0;
}
