import Data.List
import Debug.Trace

main = do
  [n, k] <- map read . words <$> getLine :: IO [Int]
  as <- map read . words <$> getLine :: IO [Int]
  print $ solve n k as

solve n k as =
  -- traceShow (l,r) $
  -- traceShow (lenl,lenr) $
  -- traceShow (ansl,ansr) $
  ans
  where
    (l,r) = span (>1) as
    lenl = --if length l >= k then length l + 1 else
      length l
    lenr = length r
    (ansl,next) = if lenl==0 then (0,0) else solve_ (lenl+1) k (0,0) 
    (ansr,_) = if lenr==1 then (0,0) else solve_ (lenr - next) k (0,0)
    ans = ansl + ansr
    solve_ len k (ans,next) =
      if len <= k then (ans+1,k-len)
      else solve_ (len - (k-1)) k (ans+1,0) 