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