#include <bits/stdc++.h>
using namespace std;
struct Point {
  int x, y;
  Point(int x = 0, int y = 0) : x(x), y(y) {}
};
int n, m, k, e1, e2;
char wm[1010][1010];
int step[1010][1010];
int x[4] = {1, 0, -1, 0};
int y[4] = {0, 1, 0, -1};
bool bfs(int a, int b);
int main() {
  int s1, s2;
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= n; i++) scanf("%s", wm[i] + 1);
  scanf("%d%d", &s1, &s2);
  scanf("%d%d", &e1, &e2);
  for (int i = 1; i <= n; i++) memset(step, -1, sizeof(step));
  step[s1][s2] = 0;
  if (!bfs(s1, s2)) printf("%d\n", step[e1][e2]);
  return 0;
}
bool bfs(int a, int b) {
  queue<Point> last;
  last.push(Point(a, b));
  while (!last.empty()) {
    Point temp = last.front();
    int xx = temp.x;
    int yy = temp.y;
    if (xx == e1 && yy == e2) {
      printf("%d\n", step[e1][e2]);
      return true;
    }
    int dark = step[xx][yy];
    last.pop();
    for (int i = 0; i < 4; i++) {
      int now = 1;
      int temp1 = xx + x[i];
      int temp2 = yy + y[i];
      while (now <= k && temp1 >= 1 && temp1 <= n && temp2 >= 1 && temp2 <= m &&
             wm[temp1][temp2] == '.') {
        if (step[temp1][temp2] == -1) {
          step[temp1][temp2] = dark + 1;
          step[temp1][temp2] = dark + 1;
          Point cute(temp1, temp2);
          last.push(cute);
        } else if (step[temp1][temp2] < dark + 1)
          break;
        temp1 += x[i];
        temp2 += y[i];
        now++;
      }
    }
  }
  return false;
}
