#include #include #include #include using namespace std; int main() { int T; cin >> T; for (int i = 0; i < T; ++i) { string S; cin >> S; int ans = INT_MAX; for (size_t j = 0; j < S.size() - 10; ++j) { for (size_t k = j + 4; k < S.size() - 6; ++k) { int tmp = 0; for (size_t l = 0; l < 4; ++l) { if (S[j + l] != "good"[l]) ++tmp; } for (size_t l = 0; l < 7; ++l) { if (S[k + l] != "problem"[l]) ++tmp; } ans = min(tmp, ans); } } cout << ans << endl; } }