#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e3 + 5;
int readint() {
  int x = 0, f = 1;
  char s = getchar();
  while (s < '0' || s > '9') {
    if (s == '-') f = -1;
    (s = getchar());
  }
  while (s >= '0' && s <= '9') {
    x = (x << 3) + (x << 1) + (s ^ 48);
    (s = getchar());
  }
  return x * f;
}
char a[maxn][maxn];
bool vis[maxn][maxn];
int n, m, speed;
int stx, sty, goalx, goaly;
int dx[4] = {0, 0, 1, -1}, dy[4] = {1, -1, 0, 0};
struct zz {
  int x, y, times;
  zz(){};
  zz(int X, int Y, int T) {
    x = X;
    y = Y;
    times = T;
  }
};
queue<zz> q;
void bfs() {
  q.push(zz(stx, sty, 0));
  vis[stx][sty] = 1;
  while (!q.empty()) {
    zz t = q.front();
    q.pop();
    for (int i = 0; i < 4; i++) {
      int S = speed;
      int tx = t.x, ty = t.y;
      while (S--) {
        tx = tx + dx[i], ty = ty + dy[i];
        if (tx < 1 || tx > n || ty < 1 || ty > m || a[tx][ty] == '#') break;
        if (vis[tx][ty]) continue;
        vis[tx][ty] = 1;
        if (tx == goalx && ty == goaly) {
          printf("%d\n", t.times + 1);
          exit(0);
        }
        q.push(zz(tx, ty, t.times + 1));
      }
    }
  }
}
signed main() {
  n = readint(), m = readint(), speed = readint();
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) cin >> a[i][j];
  }
  stx = readint(), sty = readint();
  goalx = readint(), goaly = readint();
  if (stx == goalx && sty == goaly) return !printf("0");
  bfs();
  puts("-1");
  return 0;
}
