#define _USE_MATH_DEFINES #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; int countDiff(const string& s, const string& t) { int n = s.size(); int diff = 0; for(int i=0; i> t; while(--t >= 0){ string s; cin >> s; int n = s.size(); vector v(n, INF); for(int i=n-7; i>=0; --i) v[i] = min(v[i+1], countDiff(s.substr(i, 7), "problem")); int ans = INF; int cnt = 0; for(int i=0; i= 0 && s.substr(i-7, 7) == "problem") ++ cnt; int diff = countDiff(s.substr(i, 4), "good") + v[i+4]; ans = min(ans, diff + cnt); } cout << ans << endl; } }