#include <iostream>
using namespace std;

int main(){
	int point = 0;
	string s;
	cin >> s;
	for(int i = 0; i < s.size(); i++) point += "gp"[i & 1] == s[i] ? 0 : "gp"[i & 1] > s[i] ? 1 : -1;
	cout << point << endl;
}