### BUGGY CODE ###

from random import randint
if randint(1,10)==1:
  from collections import deque
  import sys
  input=sys.stdin.readline
  calc=lambda x,y:x*1000007+y
  def main():
    h,w,k=map(int,input().split())
    sx,sy,tx,ty=map(int,input().split())
    b=[[-1]*(w+2)]
    for i in range(h):
      s=input()
      bb=[-1]
      for j in s:
        if j==".":bb.append(0)
        else:bb.append(-1)
      bb.append(-1)
      b.append(bb)
    b.append([-1]*(w+2))
    d=deque()
    d.append(calc(sx,sy))
    s=set()
    while d:
      x,y=divmod(d.popleft(),1000007)
      if calc(x,y)in s:
        s.discard((x,y))
        continue
      if x==tx and y==ty:
        exit(print(b[x][y]))
      for i in range(1,k+1):
        if b[x-i][y]<=b[x][y] and b[x-i][y]!=0:break
        d.append(calc(x-i,y))
        if b[x-i][y]!=0:
          s.add((x-i,y))
        b[x-i][y]=b[x][y]+1
      for i in range(1,k+1):
        if b[x+i][y]<=b[x][y] and b[x+i][y]!=0:break
        d.append(calc(x+i,y))
        if b[x+i][y]!=0:
          s.add((x+i,y))
        b[x+i][y]=b[x][y]+1
      for j in range(1,k+1):
        if b[x][y-j]<=b[x][y] and b[x][y-j]!=0:break
        d.append(calc(x,y-j))
        if b[x][y-j]!=0:
          s.add((x,y-j))
        b[x][y-j]=b[x][y]+1
      for j in range(1,k+1):
        if b[x][y+j]<=b[x][y] and b[x][y+j]!=0:break
        d.append(calc(x,y+j))
        if b[x][y+j]!=0:
          s.add((x,y+j))
        b[x][y+j]=b[x][y]+1
    print(-1)
  if __name__ == "__main__":
    main()
else:
  def main():
    import sys
    input=sys.stdin.readline
    h,w,k=map(int,input().split())
    sx,sy,tx,ty=map(int,input().split())
    calc=lambda x,y:x*1000007+y
    b=[[-1]*(w+2)]
    for i in range(h):
      s=input()
      bb=[-1]
      for j in s:
        if j==".":bb.append(0)
        else:bb.append(-1)
      bb.append(-1)
      b.append(bb)
    b.append([-1]*(w+2))
    from collections import deque
    d=deque()
    d.append((sx,sy))
    s=set()
    while d:
      x,y=d.popleft()
      if calc(x,y)in s:
        s.discard(calc(x,y))
        continue
      if x==tx and y==ty:
        exit(print(b[x][y]))
      for i in range(1,k+1):
        if b[x-i][y]<=b[x][y] and b[x-i][y]!=0:break
        d.append((x-i,y))
        if b[x-i][y]!=0:
          s.add(calc(x-i,y))
        b[x-i][y]=b[x][y]+1
      for i in range(1,k+1):
        if b[x+i][y]<=b[x][y] and b[x+i][y]!=0:break
        d.append((x+i,y))
        if b[x+i][y]!=0:
          s.add(calc(x+i,y))
        b[x+i][y]=b[x][y]+1
      for j in range(1,k+1):
        if b[x][y-j]<=b[x][y] and b[x][y-j]!=0:break
        d.append((x,y-j))
        if b[x][y-j]!=0:
          s.add(calc(x,y-j))
        b[x][y-j]=b[x][y]+1
      for j in range(1,k+1):
        if b[x][y+j]<=b[x][y] and b[x][y+j]!=0:break
        d.append((x,y+j))
        if b[x][y+j]!=0:
          s.add(calc(x,y+j))
        b[x][y+j]=b[x][y]+1
    print(-1)
  if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
input=sys.stdin.readline
h,w,k=map(int,input().split())
si,sj,ti,tj=map(int,input().split())
si-=1
sj-=1
ti-=1
tj-=1
b=[input()for _ in range(h)]
ans=[[-1]*w for _ in range(h)]
ans[si][sj]=0
from collections import deque
d=deque()
d.append((si,sj))
while d:
  x,y=d.popleft()
  if x==ti and y==tj:
    exit(print(ans[x][y]))
  for dx,dy in [[1,0],[-1,0],[0,-1],[0,1]]:
    for i in range(1,k+1):
      xx=x+dx*i
      yy=y+dy*i
      if not(0<=xx<h and 0<=yy<w) or b[xx][yy]=="@":break
      if 0<=ans[xx][yy]<=ans[x][y]:break
      if ans[xx][yy]==-1:d.append((xx,yy))
      ans[xx][yy]=ans[x][y]+1
print(-1)