#include <bits/stdc++.h>
using namespace std;
struct node {
  int x, y, w;
};
char mat[1005][1005];
int n, m, k, sx, sy, ex, ey, nx, ny, vis[1005][1005];
int dx[4] = {0, 0, 1, -1};
int dy[4] = {1, -1, 0, 0};
queue<node> q;
void bfs() {
  q.push(node{sx, sy, 0});
  vis[sx][sy] = 1;
  while (!q.empty()) {
    node u = q.front();
    q.pop();
    for (int d = 0; d < 4; d++) {
      nx = u.x, ny = u.y;
      for (int i = 1; i <= k; i++) {
        nx += dx[d], ny += dy[d];
        if (nx < 1 || nx > n || ny < 1 || ny > m || mat[nx][ny] == '#') break;
        if (nx == ex && ny == ey) {
          printf("%d\n", u.w + 1);
          return;
        }
        if (!vis[nx][ny]) {
          vis[nx][ny] = 1;
          q.push(node{nx, ny, u.w + 1});
        }
      }
    }
  }
  puts("-1");
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) cin >> mat[i][j];
  scanf("%d%d%d%d", &sx, &sy, &ex, &ey);
  if (sx == ex && sy == ey) {
    puts("0");
    return 0;
  }
  bfs();
  return 0;
}
