#include using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); int T; cin >> T; string g = "good",p = "problem"; while(T--){ string s; cin >> s; int N = s.size(); int answer = 1000; for(int i=0; i<=N-11; i++) for(int k=i+4; k<=N-7; k++){ int now = 0; for(int l=0; l<4; l++) if(s.at(i+l) != g.at(l)) now++; for(int l=0; l<7; l++) if(s.at(k+l) != p.at(l)) now++; answer = min(answer,now); } cout << answer << "\n"; } }