1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include <bits/stdc++.h>
using namespace std;

string d;
int a, b, c, maks;

int sim(int pddb, int pddd){
	int zad, ms, os;
	zad = ms = os = 0;
	if(pddb == pddd){
		for(int i = 0; i < a; i++){
			if(d[i] == '3') zad++;
			else if(d[i] == '2') ms++;
			else{
				os++;
				zad++;
			}
			if(os > b) return -1;
		}
	}
	else{
		for(int i = 0; i < pddb; i++){
			if(d[i] == '3') zad++;
			else if(d[i] == '2') ms++;
			else{
				os++;
				zad++;
			}
			if(os > b) return -1;
		}
		for(int i = pddb; i < pddb + c; i++){ 
			if(d[i] != '3') os++;
			if(os > b) return -1;
		}
		for(int i = pddd; i < pddd + c; i++){
			if(d[i] != '3') os++;
			if(os > b) return -1;
		}
		for(int i = pddd + c; i < a; i++){
			if(d[i] == '3') zad++;
			else if(d[i] == '2') ms++;
			else {
				os++;
				zad++;
			}
			if(os > b) return -1;
		}
	}
	zad += min(b - os, ms);
	return zad;
}

int main() {
	cin >> a >> b >> c;
	cin >> d;
	maks = -1;
	for(int i = 0; i <= a - c * 2; i++){
		for(int j = i + c; j <= a - c; j++) maks = max(maks, sim(i, j));
	}
	maks = max(maks, sim(0, 0));
	cout << maks;
	return 0;
}