#include <bits/stdc++.h>
using namespace std;
int main(void) {
  string X;
  int s = 0, len;
  cin >> X;
  len = X.length();
  for (int i = 0; i < X.length(); i++) {
    if (X[i] == 's') s++;
    if (s > 0 && X[i] == 't') len -= 2;
  }
  cout << len << endl;
  return 0;
}
