#include <bits/stdc++.h>
using namespace std;
int main() {
  string x;
  cin >> x;
  int sz = x.size(), s = 0;
  long long int sum = 0;
  for (int i = 0; i < x.size(); i++) {
    if (x[i] == 's') {
      s++;
    } else {
      while (s) {
        if (x[i] == 't') {
          sum += 2;
        }
        s--;
        i++;
      }
    }
  }
  cout << sz - sum;
}
