### BUGGY CODE ###

import queue
import sys
input = sys.stdin.readline

def calc_next_point(x, y, vec, dist):
    if vec == 0:
        return x-dist, y
    elif vec == 1:
        return x, y+dist
    elif vec == 2:
        return x+dist, y
    else:
        return x, y-dist

def main():
    h, w, k = map(int, input().split())
    x1, y1, x2, y2 = map(int, input().split())
    pond = [[1]*(w+2) for _ in range(h+2)]
    for i in range(1, h+1):
        s = input()
        for j in range(w):
            if s[j] == ".":
                pond[i][j+1] = 0
    q = queue.Queue()
    row = [[[float("inf")]*4 for j in range(w+2)] for i in range(h+2)]
    fs = [[[True]*4 for j in range(w+2)] for i in range(h+2)]
    rng = [i for i in range(k)]
    for i in range(4):
        row[x1][y1][i] = 0
        fs[x1][y1][i] = False
        nx, ny = calc_next_point(x1, y1, i, 1)
        if pond[nx][ny] == 0:
            row[nx][ny][i] == 1
            fs[nx][ny][i] = False
            q.put([1, nx, ny, i])
    while not q.empty():
        cost, x, y, vec = q.get()
        if x == x2 and y == y2:
            break
        for i in rng:
            nx, ny = calc_next_point(x, y, vec, i)
            if pond[nx][ny] == 1:
                break
            if row[nx][ny][vec] > cost:
                row[nx][ny][vec] = cost
            fs[nx][ny][vec] = False
            for j in range(4):
                mx, my = calc_next_point(nx, ny, j, 1)
                if pond[mx][my] == 1:
                    continue
                if row[mx][my][j] <= cost+1:
                    continue
                if i < k-1 and j == vec:
                    continue
                if row[mx][my][j] > cost+1 and fs[mx][my][j] :
                    row[mx][my][j] = cost+1
                    fs[mx][my][j] = False
                    q.put([cost+1, mx, my, j])
    ans = min(row[x2][y2])
    if ans == float("inf"):
        print(-1)
    else:
        print(ans)

if __name__ == "__main__":
    main()


### FIXED CODE ###

import queue
import sys
input = sys.stdin.readline

def calc_next_point(x, y, vec, dist):
    if vec == 0:
        return x-dist, y
    elif vec == 1:
        return x, y+dist
    elif vec == 2:
        return x+dist, y
    else:
        return x, y-dist

def main():
    h, w, k = map(int, input().split())
    x1, y1, x2, y2 = map(int, input().split())
    pond = [[[-1]*4 for j in range(w+2)] for i in range(h+2)]
    for i in range(1, h+1):
        s = input()
        for j in range(w):
            if s[j] == ".":
                for l in range(4):
                    pond[i][j+1][l] = float("inf")
    qs = [queue.Queue(), queue.Queue()]
    for i in range(4):
        pond[x1][y1][i] = 0
        qs[0].put([0, x1, y1, i])
    p = 0
    minans = float("inf")
    g = False
    while not qs[0].empty() or not qs[1].empty():
        while not qs[p].empty():
            cost, x, y, vec = qs[p].get()
            np = (p+1)%2
            if cost >= minans:
                g = True
                break
            if x == x2 and y == y2:
                if cost < minans:
                    minans = cost
                g = True
                break
            for i in range(1, k+1):
                nx, ny = calc_next_point(x, y, vec, i)
                if pond[nx][ny][vec] == -1:
                    break
                ncost = cost + 1
                if pond[nx][ny][vec] < ncost:
                    break
                if pond[nx][ny][vec] == ncost:
                    continue
                pond[nx][ny][vec] = ncost
                if nx == x2 and ny == y2:
                    if ncost < minans:
                        minans = ncost
                    g = True
                    break
                for j in range(4):
                    if i == k:
                        if j != (vec+2)%4:
                            if j == vec or pond[nx][ny][j] > ncost:
                                pond[nx][ny][j] = ncost
                                qs[np].put([ncost, nx, ny, j])
                    elif i == 1:
                        if j != vec:
                            if j == (vec+2)%4 or pond[nx][ny][j] > ncost:
                                pond[nx][ny][j] = ncost
                                qs[np].put([ncost, nx, ny, j])
                    else:
                        if j != vec and j != (vec+2)%4:
                            if pond[nx][ny][j] > ncost:
                                pond[nx][ny][j] = ncost
                                qs[np].put([ncost, nx, ny, j])
            if g:
                break
        if g:
            break
        p = (p+1)%2
    if min(pond[x2][y2]) == float("inf"):
        print(-1)
    else:
        print(min(pond[x2][y2]))

if __name__ == "__main__":
    main()