#include<bits/stdc++.h>

using namespace std;

string s;
int ans;

signed main(){
	cin >> s;
	int len = s.length();
	for(int i = 0; i < len; ++ i)
		if(i % 2){
			if(s[i] == 'g') ans ++; 
		}
		else{
			if(s[i] =='p') ans --;
		}
	cout << ans;	
}