#include <bits/stdc++.h>

using namespace std;

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