program main
  implicit none
  integer N, K, renzokui, j, sakadatu, l
  integer renzoku(10**5), saidai(10**5)
  character(10**5) s
  character c
  read(*, *) N, K
  read(*, *) s
  s = trim(s)
  c = s(1:1)
  renzokui = 1
  j = 1
  do i=2,N-1
    if (s(i:i) == c) then
      renzoku(j) = renzokui
      renzokui = 1
      j = j+1
    else
      renzokui = renzokui + 1
    end if
  end do
  if (s(N:N) == c) then
    renzoku(j) = renzokui
    renzoku(j + 1) = 1
    j = j+1
  else
    renzoku(j) = renzokui + 1
  end if
  sakadatu = 1
  do i = 1:j-K+1
    l = sum(renzoku(j:j+K-1))
    if (sakadatu < l) then
      sakadatu = l
    endif
  end do
  write(*, '(i0)') sakadatu
end program main