#include <iostream>
using namespace std;
string str;
int ans;
int main(void){
    // Your code here!
    cin >> str;
    for (int i = 0; i < str.length(); i++) {
        if (str[i] == 'p') ans++;
    }
    cout << str.length() / 2 - ans << endl;
}
