#include <bits/stdc++.h>
using namespace std;
const int WALL = 1;
const int CELL = 0;
const int INF = 1e9;
int n, m, k;
pair<int, int> start, finish;
int square[1005][1005], dist[1024][1024];
void bfs() {
  memset(dist, 0x33, sizeof(dist));
  dist[start.first][start.second] = 0;
  queue<pair<int, int>> q;
  q.push(start);
  static const int dir[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
  while (!q.empty()) {
    pair<int, int> pos = q.front();
    q.pop();
    int x = pos.first, y = pos.second;
    int d = dist[x][y];
    for (int i = 0; i < 4; i++) {
      for (int kk = 1; kk <= k; kk++) {
        int dx = x + dir[i][0] * kk, dy = y + dir[i][1] * kk;
        if (dx < 0 || dx >= n || dy < 0 || dy >= m) break;
        if (square[dx][dy] == WALL) break;
        if (d + 1 < dist[dx][dy]) {
          dist[dx][dy] = d + 1;
          q.push({dx, dy});
          if (dx == finish.first && dy == finish.second) {
            printf("%d\n", d + 1);
            exit(0);
          }
        }
      }
    }
  }
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 0; i < n; i++) {
    char z[1005];
    scanf("%s", &z);
    for (int j = 0; j < m; j++) {
      switch (z[j]) {
        case '#':
          square[i][j] = WALL;
          break;
        case '.':
          square[i][j] = CELL;
          break;
      }
    }
  }
  int x, y, x1, y1;
  scanf("%d%d%d%d", &x, &y, &x1, &y1);
  x--;
  y--;
  x1--;
  y1--;
  start = {x, y};
  finish = {x1, y1};
  bfs();
  if (dist[finish.first][finish.second] > 2 * n * m)
    printf("%d\n", -1);
  else
    printf("%d\n", dist[finish.first][finish.second]);
  return 0;
}
