#include <bits/stdc++.h>
using namespace std;
const int MaxN = 1e3;
int n, m, k;
int dx[5] = {0, -1, 0, 1, 0}, dy[5] = {0, 0, 1, 0, -1};
char a[MaxN + 5][MaxN + 5];
struct Node {
  int x, y, v;
} seq[MaxN * MaxN * 5], s, e;
struct Point {
  int t, s;
} ans[MaxN + 5][MaxN + 5][5];
bool Inque[MaxN + 5][MaxN + 5][5];
bool Check(int x, int y) {
  if (x < 1 || x > n) return 0;
  if (y < 1 || y > m) return 0;
  if (a[x][y] == '#') return 0;
  return 1;
}
void Solve() {
  memset(Inque, 0, sizeof(Inque));
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      for (int l = 1; l <= 4; l++) ans[i][j][l].t = 1 << 30, ans[i][j][l].s = 0;
  int head = 1, tail = 0;
  for (int i = 1; i <= 4; i++) {
    seq[++tail] = s;
    seq[tail].v = i;
    Inque[seq[tail].x][seq[tail].y][seq[tail].v] = 1;
    ans[seq[tail].x][seq[tail].y][seq[tail].v].t = 0;
    ans[seq[tail].x][seq[tail].y][seq[tail].v].s = 0;
  }
  while (head <= tail) {
    Node now = seq[head];
    Node p;
    if (Check(now.x + dx[now.v], now.y + dy[now.v])) {
      p.x = now.x + dx[now.v];
      p.y = now.y + dy[now.v];
      for (int j = 1; j <= 4; j++) {
        Point q = ans[now.x][now.y][now.v];
        p.v = j;
        if (p.v == now.v) {
          q.s++;
          if (q.s == k) q.s = 0, q.t++;
        } else
          q.t++, q.s = 0;
        if (q.t < ans[p.x][p.y][p.v].t ||
            (q.t == ans[p.x][p.y][p.v].t && q.s < ans[p.x][p.y][p.v].s)) {
          ans[p.x][p.y][p.v] = q;
          if (!Inque[p.x][p.y][p.v]) {
            Inque[p.x][p.y][p.v] = 1;
            seq[++tail] = p;
          }
        }
      }
    }
    Inque[now.x][now.y][now.v] = 0;
    head++;
  }
  int res = 1 << 30;
  for (int i = 1; i <= 4; i++) {
    int t = ans[e.x][e.y][i].t;
    if (ans[e.x][e.y][i].s != 0) t++;
    res = min(res, t);
  }
  if (res == 1 << 30)
    printf("-1\n");
  else
    printf("%d\n", res);
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) scanf(" %c", &a[i][j]);
  scanf("%d%d%d%d", &s.x, &s.y, &e.x, &e.y);
  Solve();
}
