#include<bits/stdc++.h>
using namespace std;
string s;
int main()
{
    int i=0,x=0,y,ans;
    cin>>s;
    int ls=s.length();
    while(i<ls)
    {
        if(s[i]=='p') x++;
        i++; 
    }
    y=i/2;
    ans=y-x;
    cout<<ans;
    return 0;
 } 
