# Original solution
import sys
input = sys.stdin.readline
from collections import deque

H,W,K=list(map(int,input().split()))
x1,y1,x2,y2=list(map(int,input().split()))
MAP2=[list(input().strip()) for i in range(H)]
MAP=[-1]*(H*W)

for i in range(H):
    for j in range(W):
        if MAP2[i][j]==".":
            MAP[i*W+j]=1<<25

def ch(x,y,tf):
    return (x*W+y)*4+tf

def back(x):
    tf=x%4
    x//=4
    return x//W,x%W,tf

Q=deque()
Q.append(ch(x1-1,y1-1,0))
Q.append(ch(x1-1,y1-1,1))
Q.append(ch(x1-1,y1-1,2))
Q.append(ch(x1-1,y1-1,3))
MAP[(x1-1)*W+y1-1]=0

while Q:
    x,y,tf=back(Q.popleft())

    if tf==0:
        if 0<=x+1<H and MAP[(x+1)*W+y]>MAP[x*W+y]:
            for i in range(1,K):
                if 0<=x+i<H and MAP[(x+i)*W+y]>MAP[x*W+y]:
                    MAP[(x+i)*W+y]=MAP[x*W+y]+1
                    Q.append(ch(x+i,y,2))
                    Q.append(ch(x+i,y,3))
                else:
                    break
            else:
                if 0<=x+K<H and MAP[(x+K)*W+y]>MAP[x*W+y]:
                    MAP[(x+K)*W+y]=MAP[x*W+y]+1
                    Q.append(ch(x+K,y,0))
                    Q.append(ch(x+K,y,2))
                    Q.append(ch(x+K,y,3))

    elif tf==1:            
        if 0<=x-1<H and MAP[(x-1)*W+y]>MAP[x*W+y]:
            for i in range(1,K):
                if 0<=x-i<H and MAP[(x-i)*W+y]>MAP[x*W+y]:
                    MAP[(x-i)*W+y]=MAP[x*W+y]+1
                    Q.append(ch(x-i,y,2))
                    Q.append(ch(x-i,y,3))
                else:
                    break

            else:
                if 0<=x-K<H and MAP[(x-K)*W+y]>MAP[x*W+y]:
                    MAP[(x-K)*W+y]=MAP[x*W+y]+1
                    Q.append(ch(x-K,y,1))
                    Q.append(ch(x-K,y,2))
                    Q.append(ch(x-K,y,3))

    elif tf==2:
        if 0<=y+1<W and MAP[x*W+y+1]>MAP[x*W+y]:
            for i in range(1,K):
                if 0<=y+i<W and MAP[x*W+y+i]>MAP[x*W+y]:
                    MAP[x*W+y+i]=MAP[x*W+y]+1
                    Q.append(ch(x,y+i,0))
                    Q.append(ch(x,y+i,1))
                else:
                    break

            else:
                if 0<=y+K<W and MAP[x*W+y+K]>MAP[x*W+y]:
                    MAP[x*W+y+K]=MAP[x*W+y]+1
                    Q.append(ch(x,y+K,0))
                    Q.append(ch(x,y+K,1))
                    Q.append(ch(x,y+K,2))
    else:
        if 0<=y-1<W and MAP[x*W+y-1]>MAP[x*W+y]:
            for i in range(1,K):
                if 0<=y-i<W and MAP[x*W+y-i]>MAP[x*W+y]:
                    MAP[x*W+y-i]=MAP[x*W+y]+1
                    Q.append(ch(x,y-i,0))
                    Q.append(ch(x,y-i,1))
                else:
                    break

            else:
                if 0<=y-K<W and MAP[x*W+y-K]>MAP[x*W+y]:
                    MAP[x*W+y-K]=MAP[x*W+y]+1
                    Q.append(ch(x,y-K,0))
                    Q.append(ch(x,y-K,1))
                    Q.append(ch(x,y-K,3))
            
if MAP[(x2-1)*W+y2-1]==1<<25:
    print((-1))
else:
    print((MAP[(x2-1)*W+y2-1]))


# Optimized solution
import sys
input = sys.stdin.readline
from collections import deque

H,W,K=list(map(int,input().split()))
x1,y1,x2,y2=list(map(int,input().split()))
MAP=[list(input().strip()) for i in range(H)]

for i in range(H):
    for j in range(W):
        if MAP[i][j]==".":
            MAP[i][j]=1<<30
        else:
            MAP[i][j]=-1

Q=deque()
Q.append((x1-1,y1-1))
MAP[x1-1][y1-1]=0

while Q:
    x,y=Q.pop()

    for i in range(1,K+1):
        if 0<=x+i<H and 0<=y<W and (MAP[x+i][y]==1<<30 or MAP[x+i][y]>MAP[x][y]):
            if MAP[x+i][y]==1<<30:
                MAP[x+i][y]=MAP[x][y]+1
                Q.appendleft((x+i,y))
        else:
            break

    for i in range(1,K+1):
        if 0<=x-i<H and 0<=y<W and (MAP[x-i][y]==1<<30 or MAP[x-i][y]>MAP[x][y]):
            if MAP[x-i][y]==1<<30:
                MAP[x-i][y]=MAP[x][y]+1
                Q.appendleft((x-i,y))
        else:
            break

    for i in range(1,K+1):
        if 0<=x<H and 0<=y+i<W and (MAP[x][y+i]==1<<30 or MAP[x][y+i]>MAP[x][y]):
            if MAP[x][y+i]==1<<30:
                MAP[x][y+i]=MAP[x][y]+1
                Q.appendleft((x,y+i))
        else:
            break

    for i in range(1,K+1):
        if 0<=x<H and 0<=y-i<W and (MAP[x][y-i]==1<<30 or MAP[x][y-i]>MAP[x][y]):
            if MAP[x][y-i]==1<<30:
                MAP[x][y-i]=MAP[x][y]+1
                Q.appendleft((x,y-i))
        else:
            break
if MAP[x2-1][y2-1]==1<<30:
    print((-1))
else:
    print((MAP[x2-1][y2-1]))