#include using namespace std; using ll = long long; int main() { ll N, K, L; string S; cin >> N >> K >> L >> S; // 1 回は操作できるか判定 string T = S + S; bool ok = false; { int len = 1; for (int i = 1; i < min(L * N, 2 * N); i++) { if (T.at(i - 1) == T.at(i)) len++; else len = 1; if (len >= K) ok = true; } } if (!ok) { cout << L * N << endl; return 0; } ll x = count(S.begin(), S.end(), '0'), y = N - x; x *= L, y *= L; ll z = (x - y) % (2 * K - 1); if (z < 0) z += 2 * K - 1; cout << max(z - 1, 2 * K - 2 - z) << endl; }