#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000 + 10;
const int inf = 0x3f3f3f3f;
const int dx[] = {0, 0, -1, 1}, dy[] = {1, -1, 0, 0};
char ss[maxn][maxn];
struct node {
  int x, y, stp;
} s, t;
int n, m, k, dis[maxn][maxn];
queue<node> q;
void bfs() {
  s.stp = 0;
  q.push(s);
  while (!q.empty()) {
    node cs = q.front();
    q.pop();
    for (int i = 0; i <= 3; ++i) {
      node ns = cs;
      ns.stp++;
      for (int j = 1; j <= k; ++j) {
        ns.x += dx[i];
        ns.y += dy[i];
        if (ns.x < 1 || ns.x > n || ns.y < 1 || ns.y > m) continue;
        if (ss[ns.x][ns.y] == '#' || cs.stp == dis[ns.x][ns.y]) break;
        if (dis[ns.x][ns.y] != inf) continue;
        if (ns.x == t.x && t.y == ns.y) {
          printf("%d\n", ns.stp);
          return;
        }
        q.push(ns);
        dis[ns.x][ns.y] = ns.stp;
      }
    }
  }
  printf("-1\n");
}
int main() {
  memset(dis, inf, sizeof(dis));
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= n; ++i) {
    scanf("%s", ss[i] + 1);
  }
  scanf("%d%d%d%d", &s.x, &s.y, &t.x, &t.y);
  if (s.x == t.x && s.y == t.y) {
    printf("0\n");
    return 0;
  }
  bfs();
  return 0;
}
