#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  int M = S.size();
  int N = 0, A = 0, B = 0;
  for (int i = 0; i < M; i++) {
    if (S[i] == 'S') {
      if (B != 0) {
        N += min(A, B) * 2;
        A = 1, B = 0;
      } else {
        A++;
      }
    } else {
      B++;
    }
  }
  N += 2 * min(A, B);
  cout << M - N << endl;
}
