#include <bits/stdc++.h>
using namespace std;
const int M = 1e3 + 10;
int dir[4][2] = {{0, 1}, {1, 0}, {-1, 0}, {0, -1}}, n, m, k, dist[M][M], sx, sy,
    tx, ty, mark[M][M];
deque<pair<int, int> > saf;
void bfs(int x, int y) {
  mark[x][y] = 1;
  saf.push_back(make_pair(x, y));
  while (saf.size()) {
    int nx = saf[0].first, ny = saf[0].second;
    for (int d = 0; d < 4; d++)
      for (int i = 1; i <= k; i++) {
        int ux = nx + dir[d][0] * i, uy = ny + dir[d][1] * i;
        if (!mark[ux][uy]) {
          dist[ux][uy] = dist[nx][ny] + 1;
          saf.push_back(make_pair(ux, uy));
          mark[ux][uy] = 1;
        } else if (mark[ux][uy] == 2 || dist[ux][uy] <= dist[nx][ny])
          break;
      }
    saf.pop_front();
  }
}
int main() {
  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      char c;
      cin >> c;
      if (c == '#') mark[i][j] = 2;
    }
  for (int i = 0; i < M; i++)
    mark[i][0] = mark[0][i] = mark[n + 1][i] = mark[i][m + 1] = 2;
  cin >> sx >> sy >> tx >> ty;
  bfs(sx, sy);
  if (dist[tx][ty] || (tx == sx && ty == sy))
    cout << dist[tx][ty];
  else
    cout << -1;
  return 0;
}
