#include <bits/stdc++.h>
using namespace std;
const int inf = ~0u >> 2;
const int N = 1e3 + 3;
char g[N][N];
int d[N][N];
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
int n, m, k, sx, sy, fx, fy;
bool valid(int x, int y) { return x > -1 and x < n and y > -1 and y < m; }
queue<pair<int, int>> q;
int bfs(int ux, int uy) {
  d[ux][uy] = 0;
  q.emplace(ux, uy);
  int vx, vy;
  while (q.size()) {
    tie(ux, uy) = q.front();
    q.pop();
    for (int i = 0; i < 4; ++i) {
      vx = ux;
      vy = uy;
      for (int j = 0; j < k; ++j) {
        vx += dx[i];
        vy += dy[i];
        if (!valid(vx, vy)) break;
        if (g[vx][vy] == '#') break;
        if (d[vx][vy] == inf) {
          d[vx][vy] = d[ux][uy] + 1;
          q.emplace(vx, vy);
        } else if (d[vx][vy] < d[ux][uy] + 1)
          break;
      }
    }
  }
  if (d[fx][fy] == inf) return -1;
  return d[fx][fy];
}
int main() {
  scanf("%d %d %d", &n, &m, &k);
  for (int i = 0; i < n; ++i) scanf(" %s", g[i]);
  scanf("%d %d %d %d", &sx, &sy, &fx, &fy);
  --sx;
  --sy;
  --fx;
  --fy;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j) d[i][j] = inf;
  printf("%d\n", bfs(sx, sy));
  return 0;
}
