N, K = gets.split.map(&:to_i)
S = gets.chomp.chars.map(&:to_i)

remain = 0
ans = 0
k = K
visited = Hash.new
buy_hist = []
i = 0

loop do
  cur_remain = remain
  buy_cnt = 0

  if visited[cur_remain]
    s, _ = visited[cur_remain]
    d = k / N
    arr = buy_hist[s..]
    ans += d * arr.sum
    k %= N
  end

  S.each do |s|
    if remain <= 0
      buy_cnt += 1
    else
      remain -= 1
    end

    k -= 1
    remain += s

    break if k <= 0
  end

  visited[cur_remain] = [i, buy_cnt]
  buy_hist << buy_cnt
  ans += buy_cnt
  i += 1

  break if buy_cnt == 0 && cur_remain < remain
  break if k <= 0
end

puts ans