N, A, B = map(int, input().split()) S = str(input()) rle = [] concnt = 0 now_idx = 0 while True: if now_idx >= N - 2: if concnt >= 1: rle.append(concnt) break elif S[now_idx:(now_idx + 3)] == 'con': now_idx += 3 concnt += 1 else: now_idx += 1 if concnt >= 1: rle.append(concnt) concnt = 0 INF = N // 3 + 1 MAX_J = (N + 3) // 6 + 1 divA = [0 for _ in range(INF)] divB = [0 for _ in range(INF)] for i in range(INF): divA[i] = i // A divB[i] = i // B dp1 = [-INF for _ in range(MAX_J)] dp2 = [-INF for _ in range(MAX_J)] dp1[0] = 0 now = 0 for i in range(len(rle)): now += divA[rle[i]] for j in range(now + 1): for k in range(divA[rle[i]] + 1): if j + k >= MAX_J: continue val = divB[rle[i] - A * k] if dp2[j + k] < dp1[j] + val: dp2[j + k] = dp1[j] + val for j in range(now + 1): dp1[j] = dp2[j] dp2[j] = -INF #print(dp1[0:5]) ans = 0 for j in range(MAX_J): if dp1[j] >= j - 1: ans = max(ans, 2 * j - 1) if dp1[j] >= j: ans = max(ans, 2 * j) print(ans)