#include <iostream>
using namespace std;

int main(){
	string s;
	cin >> s;
	int n = s.length();
	int ans = 0;
	for(int i=0; i<n; i++){
		if(i < (n+1)/2 && s[i]=='p') ans--;
		if(i >= (n+1)/2 && s[i]=='g') ans++;
	}
	cout << ans << endl;
	return 0;
}