# 5 2
# 11001

class String
  def count1
    max = 0
    tmp = 0
    was1 = true
    self.chars do |i|
      if was1
        if i.to_i == 1
          tmp += 1
          max = tmp if max < tmp
        else
          was1 = false
          tmp = 0
        end
      elsif i.to_i == 1
        was1 = true
        tmp += 1
        max = tmp if max < tmp
      end
    end
    max
  end

  def reverse(r,l)
    length = l - r + 1
    out = "#{self}"
    length.times do |i|
      a = out[r + i]
      a = a.to_i
      a += 1
      a = a % 2
      out[r + i] = a.to_s
    end
    out
  end

  def max1
    out = "#{self}"
    out_count1 = out.count1
    length = out.length
    length.times do |r|
      (length-r).times do |l|
        tmp = self.reverse(r,l+r)
        tmp_count1 = tmp.count1
        if out_count1 < tmp_count1
          out = tmp
          out_count1 = tmp_count1
        end
      end
    end
    out
  end

  def maxk(k)
    out = "#{self}"
    k.times do
      out = out.max1
    end
    out
  end
end

n,k = gets.chomp.split(/[\u00A0\s]/).map(&:to_i)
s = gets.chomp

puts s.maxk(k).count1
