#include <bits/stdc++.h>
using namespace std;
int main(void) {
  string x;
  while (cin >> x) {
    stack<char> sk;
    int len = x.size();
    sk.push(x[0]);
    for (int i = 1; i < len; ++i) {
      char top = sk.top();
      if (top == 's' && x[i] == 't') {
        sk.pop();
      } else
        sk.push(x[i]);
    }
    cout << sk.size() << endl;
  }
  return 0;
}
