#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  string s;
  cin >> s;
  int sn = 0, tn = 0;
  for (auto c : s) {
    if (c == 's') {
      sn++;
    } else {
      if (sn > 0)
        sn--;
      else
        tn++;
    }
  }
  cout << tn * 2;
}
