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