### BUGGY CODE ###

#!/usr/bin/env python3
import sys
from heapq import heappush, heappop, heapify
sys.setrecursionlimit(10**8)
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return [LIST() for _ in range(n)]


INF = float("inf")
MOD = 10**9 + 7

def array(*args, initial=0):
    pre = "[" * len(args)
    post = ""
    for a in args[::-1]:
        post += " for _ in range(" + str(a) + ")]"
    S = pre + "{}".format(initial) + post
    return eval(S)


def main():
    H, W, K = MAP()
    x1, y1, x2, y2 = MAP()
    # 空間はINF,壁は-1, →↑←↓
    pond = array(H + 2, W + 2, 4, initial=-1)
    for h in range(1, H + 1):
        for w, c in enumerate(input(), start=1):
            if c == ".":
                for i in range(4):
                    pond[h][w][i] = INF
    q = []
    # 距離(), x, y, 方向
    heappush(q, ((0, 0), x1, y1, 0))
    heappush(q, ((0, 0), x1, y1, 1))
    heappush(q, ((0, 0), x1, y1, 2))
    heappush(q, ((0, 0), x1, y1, 3))
    DX = (1, 0, -1, 0)
    DY = (0, 1, 0, -1)
    while q:
        (a0, a1), x, y, d = heappop(q)
        # 順方向へ進む
        nx = x + DX[d]
        ny = y + DY[d]
        # print((a0, a1), x, y, d, nx, ny)
        if pond[nx][ny][0] == -1:     # 行き止まりなら何もせず
            continue
        if pond[nx][ny][(d + 1) % 4] > a0 + 1:
            pond[nx][ny][(d + 1) % 4] = a0 + 1
            heappush(q, ((a0 + 1, 0), nx, ny, (d + 1) % 4))
        if pond[nx][ny][(d - 1) % 4] > a0 + 1:
            pond[nx][ny][(d - 1) % 4] = a0 + 1
            heappush(q, ((a0 + 1, 0), nx, ny, (d - 1) % 4))
        if pond[nx][ny][d] >= a0 + 1:
            pond[nx][ny][d] = a0 + 1
            if a1 + 1 < K:
                heappush(q, ((a0, a1 + 1), nx, ny, d))
            else:
                heappush(q, ((a0 + 1, 0), nx, ny, d))
        if (nx, ny) == (x2, y2):
            print(a0 + 1)
            return
    print(-1)
    return


if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
INF = float("inf")


def main():
    H, W, K = map(int, input().split())
    x1, y1, x2, y2 = map(lambda x: int(x)-1, input().split())
    c = []
    for i in range(H):
        c.append(input())
    # 移動方法が4*K個考えられる無向グラフ
    # 到達可能性は最短経路を求めるだけでよい
    # 全ての箇所を探索するとO(H*W)必要に見える。
    # あれ、HW<=10^6がある。難しさは何？Kが大きいから枝が多すぎるということか。
    DX = [1, 0, -1,  0]
    DY = [0, 1, 0, -1]

    # 方向付きで、ダイクストラ法を使います。
    dist = [[-1]*W for _ in range(H)]
    dist[x1][y1] = 0
    Q = []                      # ヒープなんてもう知らない！
    M = 10**6
    Q.append((0, x1, y1, 0b1111))
    i = 0

    while i < len(Q):
        curr, x, y, DXY = Q[i]
        for j in range(4):
            if (DXY >> j) & 1 == 0:
                continue
            dx, dy = DX[j], DY[j]
            for k in range(1, K+1):
                X = x+k*dx
                Y = y+k*dy
                if not (0 <= X < H):
                    break
                if not (0 <= Y < W):
                    break
                if 0 < dist[X][Y] < curr+1:
                    break
                if dist[X][y] == curr+1:
                    continue
                if c[X][Y] == "@":
                    break
                dist[X][Y] = curr+1
                flag = (1 << ((j+1) % 4)) | (1 << ((j-1) % 4))
                if k != K:
                    Q.append((curr+1, X, Y, flag))
                else:
                    flag |= 1 << j % 4
                    Q.append((curr+1, X, Y, flag))
            if 0 < dist[x2][y2]:
                print(dist[x2][y2])
                return
        i += 1
    print(-1)
    return


if __name__ == '__main__':
    main()