#include #include #include #include using namespace std; int main(){ int N, A, B; cin >> N >> A >> B; string S; cin >> S; vector rle(0); int concnt = 0; int now_idx = 0; while(true){ if (now_idx >= N - 2){ if (concnt >= 1){ rle.push_back(concnt); } break; } else if (S.substr(now_idx, 3) == "con"){ now_idx += 3; concnt++; } else{ now_idx++; if (concnt >= 1){ rle.push_back(concnt); } concnt = 0; } } int INF = 50000; int len = rle.size(); vector dp1(8338, INF * -1); vector dp2(8338, INF * -1); dp1[0] = 0; int times = 0; for (int i = 0; i < len; i++){ times += rle[i] / A; for (int j = 0; j <= times; j++){ for (int k = 0; k <= (rle[i] / A); k++){ if (j + k >= 8338) continue; dp2[j + k] = max(dp2[j + k], dp1[j] + (rle[i] - A * k) / B); } } for (int j = 0; j < 8338; j++){ dp1[j] = dp2[j]; dp2[j] = INF * -1; } } int ans = 0; for (int j = 0; j < 8338; j++){ if (dp1[j] >= j - 1) ans = max(ans, 2 * j - 1); if (dp1[j] >= j) ans = max(ans, 2 * j); } cout << ans << endl; }