using static System.Math; using System; public class Hello { static void Main() { string[] line = Console.ReadLine().Trim().Split(' '); var n = int.Parse(line[0]); var k = int.Parse(line[1]); var s = Console.ReadLine().Trim(); getAns(n, k, s); } static void getAns(int n, int k, string s) { var m = k / n; var mod = k % n; if (m == 0) { Console.WriteLine(sim0(n, k, s)); return; } if (mod == 0) m--; var a = 0; foreach (var x in s) a += x - '0'; var b = Max(0, n - a); var nk = k - n * (m - 1); var ans = sim0(n + n, nk, s + s) + b * (m - 1); Console.WriteLine(ans); } static int sim0(int n, int k, string s) { if (k == 1) return 1; var buy = 1; var atari = s[0] - '0'; var eat = 1; var p = 1; while (p < n) { if (atari > 0) atari--; else buy++; atari += s[p] - '0'; eat++; if (eat == k) return buy; p++; } return -1; } }