import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int N = scan.nextInt(); int K = scan.nextInt(); String S = scan.next(); int l = S.length(); int k = 0; if(K <= N) { int cnt = 0; int a = 0; for(int i = 0; i < N; i++) { if(a == 0) { cnt++; }else { a--; } if(K <= 0) { break; } if(S.charAt(i) == '1') { a++; K--; }else if(S.charAt(i) == '2') { K -= 2; a+=2; } } System.out.println(cnt); System.exit(0); } int a = 0; int cnt = 0; for(int i = 0; i < N; i++) { if(S.charAt(i) == '2') { a += 2; }else if(S.charAt(i) == '1') { a ++; } } if(a >= l) { cnt = 0; a = 0; for(int i = 0; i < N; i++) { if(a == 0) { cnt++; }else { a--; } if(S.charAt(i) == '1') { a++; K--; }else if(S.charAt(i) == '2') { K -= 2; a += 2; } } System.out.println(cnt); System.exit(0); } cnt = 0; int t = l - a; int c = 0; int d = 0; for(int i = 0; i < N; i++) { if(d == 0) { c++; }else { d--; } if(S.charAt(i) == '1') { d++; }else if(S.charAt(i) == '2') { d += 2; } } if(K % N == 0) { int ans = t * (K / N - 1) + c; System.out.println(ans); }else { int b = K / N; int res = K - b * N; for(int i = 0; i < res; i++) { if(d == 0) { c++; }else { d--; } if(S.charAt(i) == '1') { d++; }else if(S.charAt(i) == '2') { d += 2; } } int ans = (b - 1) * (N - 1) + c; System.out.println(ans); } } }