package main import ( "bufio" "fmt" "os" "strconv" ) var sc = bufio.NewScanner(os.Stdin) func main() { sc.Split(bufio.ScanWords) n, k := nextInt(), nextInt() s := nextLine() ns := make([]int, n) for i, r := range s { v, _ := strconv.Atoi(string(r)) ns[i] = v } c, w := 0, 0 for i, v := range ns { if i+1 == k { fmt.Println(c) return } if w == 0 { c++ } else { w-- } w += v } if w > c { fmt.Println(c) return } k -= n c += (k / n) * (c - w) k %= n for i := 0; i < k; i++ { if w == 0 { c++ } else { w-- } w += ns[i] } fmt.Println(c) } func nextLine() string { sc.Scan() return sc.Text() } func nextInt() int { i, _ := strconv.Atoi(nextLine()) return i }