#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1024000000,1024000000")
using namespace std;
const int INF = 0x3f3f3f3f;
const double eps = 1e-8;
const double PI = acos(-1.0);
int n, m, k;
bool mat[1005][1005] = {}, vis[1005][1005] = {};
int dir[4][2] = {{0, -1}, {0, 1}, {1, 0}, {-1, 0}};
struct node {
  int x, y, cnt;
} tmp, s, e, tmp2;
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 0; i < n; i++) {
    char ch[1005];
    scanf("%s", ch);
    for (int j = 0; j < m; j++)
      if (ch[j] == '#') mat[i][j] = 1;
  }
  scanf("%d%d%d%d", &s.x, &s.y, &e.x, &e.y);
  s.x--;
  s.y--;
  e.x--;
  e.y--;
  queue<node> Q;
  s.cnt = 0;
  e.cnt = INF;
  vis[s.x][s.y] = 1;
  Q.push(s);
  if (s.x == e.x && s.y == e.y) {
    printf("0\n");
    return 0;
  }
  while (!Q.empty()) {
    tmp = Q.front();
    Q.pop();
    for (int i = 0; i < 4; i++) {
      for (int j = 1; j <= k; j++) {
        tmp2.x = tmp.x + j * dir[i][0], tmp2.y = tmp.y + j * dir[i][1];
        if (tmp2.x < 0 || tmp2.y < 0 || tmp2.x >= n || tmp2.y >= m ||
            mat[tmp2.x][tmp2.y] == 1)
          break;
        if (vis[tmp2.x][tmp2.y]) continue;
        vis[tmp2.x][tmp2.y] = 1;
        if (e.x == tmp2.x && e.y == tmp2.y) {
          printf("%d\n", tmp.cnt + 1);
          return 0;
        }
        tmp2.cnt = tmp.cnt + 1;
        Q.push(tmp2);
      }
    }
  }
  printf("-1\n");
  return 0;
}
