### BUGGY CODE ###

from collections import deque

h, w, k = map(int, input().split())
x1, y1, x2, y2 = map(int, input().split())

grid = [None]*h
for i in range(h):
  grid[i] = input()

not_yet = deque([])
already = [[False]*w for _ in range(h)]
dist = [[0]*w for _ in range(h)]

not_yet.append((x1-1, y1-1))
already[x1-1][y1-1] = True

while not_yet:
  key = not_yet.popleft()
  k1, k2 = key[0], key[1]
  
  for i in range(k1-1, max([-1, k1-k-1]), -1):
    if not already[i][k2] and grid[i][k2] == ".":
      dist[i][k2] = dist[k1][k2] + 1
      already[i][k2] = True
      not_yet.append((i, k2))
    elif grid[i][k2] == "@":
      break
  for i in range(k1+1, min([h, k1+k+1])):
    if not already[i][k2] and grid[i][k2] == ".":
      dist[i][k2] = dist[k1][k2] + 1
      already[i][k2] = True
      not_yet.append((i, k2))
    elif grid[i][k2] == "@":
      break
  for i in range(k2-1, max([-1, k2-k-1]), -1):
    if not already[k1][i] and grid[k1][i] == ".":
      dist[k1][i] = dist[k1][k2] + 1
      already[k1][i] = True
      not_yet.append((k1, i))
    elif grid[k1][i] == "@":
      break
  for i in range(k2+1, min([w, k2+k+1])):
    if not already[k1][i] and grid[k1][i] == ".":
      dist[k1][i] = dist[k1][k2] + 1
      already[k1][i] = True
      not_yet.append((k1, i))
    elif grid[k1][i] == "@":
      break
      
if dist[x2-1][y2-1] == 0:
  print(-1)
else:
  print(dist[x2-1][y2-1])

### FIXED CODE ###

import sys
from collections import deque
input = sys.stdin.readline

def main():
    h, w, k = map(int, input().split())
    sx, sy, gx, gy = map(int, input().split())

    c = [input() for i in range(h)]

    not_yet = deque([(sx-1, sy-1)])
    dist = [[-1]*w for i in range(h)]
    dist[sx-1][sy-1] = 0
    already = [[False]*w for i in range(h)]
    already[sx-1][sy-1] = True

    while not_yet:
        x, y = not_yet.popleft()
        d = dist[x][y]

        for i in range(x+1, x+k+1):
            if i >= h or c[i][y] == "@":
                break
            if already[i][y] and dist[i][y] < d + 1:
                break
            if already[i][y] and dist[i][y] == d + 1:
                continue
            dist[i][y] = d + 1
            already[i][y] = True
            not_yet.append((i, y))

        for i in range(x-1, x-k-1, -1):
            if i < 0 or c[i][y] == "@":
                break
            if already[i][y] and dist[i][y] < d + 1:
                break
            if already[i][y] and dist[i][y] == d + 1:
                continue
            dist[i][y] = d + 1
            already[i][y] = True
            not_yet.append((i, y))
        
        for i in range(y+1, y+k+1):
            if i >= w or c[x][i] == "@":
                break
            if already[x][i] and dist[x][i] < d + 1:
                break
            if already[x][i] and dist[x][i] == d + 1:
                continue
            dist[x][i] = d + 1
            already[x][i] = True
            not_yet.append((x, i))

        for i in range(y-1, y-k-1, -1):
            if i < 0 or c[x][i] == "@":
                break
            if already[x][i] and dist[x][i] < d + 1:
                break
            if already[x][i] and dist[x][i] == d + 1:
                continue
            dist[x][i] = d + 1
            already[x][i] = True
            not_yet.append((x, i))

    ans = dist[gx-1][gy-1]
    print(ans)

    
if __name__ == "__main__":
    main()