#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int MaxN = 1e3 + 5;
const int INF = 0x3f3f3f3f;
int n, m, k;
int nx, ny, mx, my;
char ma[MaxN][MaxN];
int flag[MaxN][MaxN];
int vis[MaxN][MaxN];
int fx[5] = {INF, 0, 0, 1, -1};
int fy[5] = {INF, 1, -1, 0, 0};
struct node {
  int x;
  int y;
  int step;
} now, nex;
bool check(node swp) {
  if (swp.x <= 0 || swp.x > n || swp.y <= 0 || swp.y > m) return true;
  if (ma[swp.x][swp.y] == '#') return true;
  if (flag[swp.x][swp.y] != INF && flag[swp.x][swp.y] < now.step + 1)
    return true;
  return false;
}
void BFS() {
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      vis[i][j] = 1;
      flag[i][j] = INF;
    }
  }
  queue<node> q;
  now.x = nx;
  now.y = ny;
  now.step = 0;
  flag[nx][ny] = 0;
  q.push(now);
  while (!q.empty()) {
    now = q.front();
    q.pop();
    vis[now.x][now.y] = 1;
    for (int i = 1; i <= 4; i++) {
      for (int j = 1; j <= k; j++) {
        nex.x = now.x + fx[i] * j;
        nex.y = now.y + fy[i] * j;
        nex.step = now.step + 1;
        if (check(nex)) {
          break;
        } else if (nex.step <= flag[nex.x][nex.y] && vis[nex.x][nex.y] == 1) {
          vis[nex.x][nex.y] = 0;
          flag[nex.x][nex.y] = nex.step;
          q.push(nex);
        }
      }
    }
  }
}
int main() {
  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++) {
    scanf("%s", ma[i] + 1);
  }
  cin >> nx >> ny >> mx >> my;
  BFS();
  if (flag[mx][my] == INF) {
    cout << -1 << endl;
  } else {
    cout << flag[mx][my] << endl;
  }
  return 0;
}
