#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const int MOD = 1e9 + 7;
int dr[] = {-1, 0, 1, 0};
int dc[] = {0, 1, 0, -1};
int n, m, k, dist[1000][1000], rr[2], cc[2];
char grid[1000][1001];
queue<pair<int, int> > q;
int main() {
  scanf("%d %d %d", &n, &m, &k);
  for (int i = 0; i < n; i++) scanf("%s", grid[i]);
  for (int i = 0; i < 2; i++) {
    scanf("%d %d", &rr[i], &cc[i]);
    rr[i]--;
    cc[i]--;
  }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) dist[i][j] = INF;
  q.push({rr[0], cc[0]});
  dist[rr[0]][cc[0]] = 0;
  while (!q.empty()) {
    pair<int, int> top = q.front();
    q.pop();
    int r = top.first;
    int c = top.second;
    for (int i = 0; i < 4; i++) {
      int new_r = r;
      int new_c = c;
      for (int j = 0; j < k; j++) {
        new_r += dr[i];
        new_c += dc[i];
        if (new_r < 0 || new_r >= n || new_c < 0 || new_c >= m) break;
        if (grid[new_r][new_c] == '#') break;
        if (dist[new_r][new_c] > dist[r][c] + 1) {
          dist[new_r][new_c] = dist[r][c] + 1;
          q.push({new_r, new_c});
        } else if (dist[new_r][new_c] < dist[r][c] + 1)
          break;
      }
    }
  }
  int ans = dist[rr[1]][cc[1]];
  if (ans == INF) ans = -1;
  printf("%d\n", ans);
  return 0;
}
