#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; while (true) { if (x < y) swap(x, y); if (x < K) break; ll z = x / K; x -= z * K; y += z * (K - 1); } cout << x + y << endl; }