#include using lint=long long; lint dist(std::string s,std::string t){ assert(s.length()==t.length()); lint n=s.length(); lint ans=0; for(lint i=0;iy)x=y;} int main(){ std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false); std::cout.setf(std::ios_base::fixed);std::cout.precision(15); std::string good="good"; std::string problem="problem"; lint q;std::cin>>q; while(q--){ std::string s;std::cin>>s; lint n=s.length(); lint ans=11; lint min=good.size(); for(lint i=0;i<=n-good.length()-problem.length();i++){ cmn(min,dist(good,s.substr(i,good.length()))); cmn(ans,min+dist(problem,s.substr(i+good.length(),problem.length()))); } std::cout<