#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
int xx[] = {0, 0, 1, -1};
int yy[] = {1, -1, 0, 0};
int n, m, k;
int sx, sy, tx, ty;
char s[1005][1005];
bool in(int x, int y) { return x >= 0 && y >= 0 && x < n && y < m; }
struct node {
  int x, y, dir;
};
int vis[1005][1005][4];
int dis[1005][1005][4];
void bfs() {
  memset(dis, inf, sizeof(dis));
  queue<node> q;
  for (int i = 0; i < 4; i++) {
    dis[sx][sy][i] = 0;
    vis[sx][sy][i] = 0;
    q.push((node){sx, sy, i});
  }
  while (!q.empty()) {
    node u = q.front();
    q.pop();
    for (int i = 0; i < 4; i++) {
      int fx = u.x + xx[i];
      int fy = u.y + yy[i];
      if (!in(fx, fy) || s[fx][fy] == '#') continue;
      if (i == u.dir) {
        int tmp = (vis[u.x][u.y][u.dir] % k == 0 ? 1 : 0);
        if (dis[fx][fy][i] > dis[u.x][u.y][u.dir] + tmp) {
          dis[fx][fy][i] = dis[u.x][u.y][u.dir] + tmp;
          vis[fx][fy][i] = vis[u.x][u.y][u.dir] + 1;
          q.push((node){fx, fy, i});
        }
      } else {
        if (dis[fx][fy][i] > dis[u.x][u.y][u.dir] + 1) {
          dis[fx][fy][i] = dis[u.x][u.y][u.dir] + 1;
          vis[fx][fy][i] = 1;
          q.push((node){fx, fy, i});
        }
      }
    }
  }
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 0; i < n; i++) {
    scanf("%s", s[i]);
  }
  scanf("%d%d", &sx, &sy);
  scanf("%d%d", &tx, &ty);
  sx--, sy--, tx--, ty--;
  bfs();
  int ans = inf;
  for (int i = 0; i < 4; i++) ans = min(ans, dis[tx][ty][i]);
  if (ans == inf) {
    printf("-1\n");
  } else {
    printf("%d\n", ans);
  }
  return 0;
}
