//The ごり押し★ #include #include #include #include #include #include #include #define T_MAX 100 #define S_LEN 100 using namespace std; typedef unsigned long long ULL; typedef long long LL; int main() { int T; string S[T_MAX]; cin >> T; for (int i = 0; i < T; ++i) cin >> S[i]; for (int s = 0; s < T; ++s) { int len = S[s].size(); int goodscore = 0; int problemscore = 0; for (int i = 0; i < len - 10; ++i) { int score = 0; if (S[s][i] == 'g') { ++score; } if (S[s][i + 1] == 'o') { ++score; } if (S[s][i + 2] == 'o') { ++score; } if (S[s][i + 3] == 'd') { ++score; } if (score > goodscore) goodscore = score; for (int j = i+4; j < len-6; ++j) { score = 0; if (S[s][j] == 'p') { ++score; } if (S[s][j+1] == 'r') { ++score; } if (S[s][j+2] == 'o') { ++score; } if (S[s][j+3] == 'b') { ++score; } if (S[s][j+4] == 'l') { ++score; } if (S[s][j+5] == 'e') { ++score; } if (S[s][j+6] == 'm') { ++score; } if (score > problemscore) problemscore = score; } } cout << 11 - goodscore - problemscore << endl; } return 0; }