#include #include int main(){ int N, K; scanf("%d %d", &N, &K); char ice[100]; scanf("%s", ice); for(int i=N;i<2*N;i++){ice[i] = ice[i-N];} bool bought[100]; std::fill(bought, bought+2*N, false); int cost[100], last = 0; std::fill(cost, cost+2*N, 0); for(int i=0;i<2*N;i++){ if(!bought[i]){ cost[i] = 1; } if(ice[i] == '1'){ if(last+1 < 2*N){bought[last+1] = true; last += 1;} }else if(ice[i] == '2'){ if(last+1 < 2*N){bought[last+1] = true; last += 1;} if(last+1 < 2*N){bought[last+1] = true; last += 1;} } last = std::max(i+1, last); } for(int i=1;i= N){ res += cost[2*N-1]; K -= N; } res += K>1?cost[K-1]:0; } printf("%d\n", res); }