#include<iostream>
using namespace std;
int main(){
	string s;
	cin>>s;
	int l=s.size();
	int i,r=0,p=0;
	for(i=0;i<l;i++){
		if(s[i]=='g')
		r++;
		else
		p++;
	}
	cout<<l/2-p<<endl;
	
	
	
	
	return 0;
} 