import java.util.ArrayList; import java.util.HashSet; import java.util.Scanner; public class Main { static int N, K; static String S; static private void solve() { // 一周分測定する int buybar = 0; int nextbar = 0; int freebar = 0; for (int k = 0; k < N; k++) { if (freebar > 0) freebar--; else buybar++; switch (S.charAt(k)) { case '0': break; case '1': freebar++; break; case '2': freebar+=2; break; } if((k+1) == K) { System.out.println(buybar); return; } } // 一周するときに int loopbuy = buybar; int loopfree = freebar; if(loopbuy <= loopfree) { System.out.println(loopbuy); return; } buybar = 0; nextbar = 0; freebar = 0; int loop = K/N; int k = loop * N; freebar = loopfree; buybar = loopbuy + (loopbuy - loopfree) * (loop - 1); /*for (int i = 0; i < loop; i++) { if(freebar >= loopbuy) { freebar -= loopbuy; } else { buybar += loopbuy - freebar; freebar = 0; } freebar += loopfree; }*/ for (; k < K; k++) { if (freebar > 0) freebar--; else buybar++; switch (S.charAt(k%N)) { case '0': break; case '1': freebar++; break; case '2': freebar+=2; break; } } System.out.println(buybar); } static public void main(String[] args) { Scanner sca = new Scanner(System.in); N = sca.nextInt(); K = sca.nextInt(); S = sca.next(); solve(); } }