#include <bits/stdc++.h>
using namespace std;
const int d[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
int n, m, k, sx, sy, qx, qy;
char ch[1005][1005];
bool vis[1005][1005];
int bfs() {
  int i, j, dx, dy, wx, wy, cost;
  queue<int> x, y, t;
  x.push(sx);
  y.push(sy);
  t.push(0);
  while (!x.empty()) {
    wx = x.front();
    wy = y.front();
    cost = t.front();
    x.pop();
    y.pop();
    t.pop();
    if (wx == qx && wy == qy) return cost;
    for (i = 0; i < 4; i++) {
      for (j = 1; j <= k; j++) {
        dx = wx + d[i][0] * j;
        dy = wy + d[i][1] * j;
        if (dx <= 0 || dx > n || dy <= 0 || dy > m) break;
        if (ch[dx][dy] == '#') break;
        if (!vis[dx][dy]) {
          if (dx == qx && dy == qy) return cost + 1;
          x.push(dx);
          y.push(dy);
          t.push(cost + 1);
          vis[dx][dy] = true;
        }
      }
    }
  }
  return -1;
}
int main() {
  int i, j;
  cin >> n >> m >> k;
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      cin >> ch[i][j];
      if (ch[i][j] == '#') {
        vis[i][j] = true;
      }
    }
  }
  cin >> sx >> sy >> qx >> qy;
  cout << bfs() << endl;
  return 0;
}
