{-# LANGUAGE FlexibleContexts #-}

import Control.Monad
import qualified Data.ByteString.Char8 as C
import Data.Char
import qualified Data.Set as S
import Data.Ix
import Data.List
import Data.Maybe

main = sol <$> get <*> get <*> getT >>= print

get = unfoldr (C.readInt . C.dropWhile (<'0')) <$> C.getLine

getT = C.filter (not . isSpace) <$> C.getContents

sol [h,w,k] [x1,y1,x2,y2] tbl = fromMaybe (-1) $ f 0 (S.empty,S.singleton p1)
  where
  p1 = (x1,y1)
  p2 = (x2,y2)
  f i (core,skin)
    | S.null skin         = Nothing
    | p2 `S.member` skin  = Just i
    | otherwise           = f (i+1) (S.union core skin,skin')
    where
    skin' = S.foldr' (S.union . nbr core) S.empty skin
  nbr core (x,y) = S.fromList . foldr1 (++) $ map (takeWhile g) [
    [(x+j,y) | j <- [1..k]],[(x-j,y) | j <- [1..k]],
    [(x,y+j) | j <- [1..k]],[(x,y-j) | j <- [1..k]]]
    where
    g p@(x,y) = inRange (1,h) x && inRange (1,w) y && ok p && p `S.notMember` core
    ok (r,c) = C.index tbl ((r-1)*w+c-1) == '.'