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