#include <bits/stdc++.h>
inline int sbt(int x) { return __builtin_popcount(x); }
using namespace std;
char a[1005][1005];
int n, m, k, srcx, srcy, desx, desy;
int dis[1005][1005];
pair<int, int> p;
pair<int, int> to;
pair<int, int> destination;
int dx[][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
int main() {
  cin.sync_with_stdio(false);
  cout.sync_with_stdio(false);
  cin >> n >> m >> k;
  for (int i = 0; i <= n + 1; i++) {
    for (int j = 0; j <= m + 1; j++) {
      dis[i][j] = INT_MAX;
    }
  }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) cin >> a[i][j];
  cin >> srcx >> srcy >> desx >> desy;
  srcx--;
  srcy--;
  desx--;
  desy--;
  destination = make_pair(desx, desy);
  queue<pair<int, int>> q;
  q.push(make_pair(srcx, srcy));
  dis[srcx][srcy] = 0;
  while (!q.empty()) {
    p = q.front();
    q.pop();
    if (p == destination) {
      cout << dis[destination.first][destination.second] << endl;
      return 0;
    }
    for (int i = 0; i < 4; i++) {
      to = p;
      for (int j = 0; j < k; j++) {
        to = make_pair((to.first + dx[i][0]), (to.second + dx[i][1]));
        if (to.first >= 0 && to.first < n && to.second >= 0 && to.second < m &&
            a[to.first][to.second] != '#') {
          if (dis[to.first][to.second] <= dis[p.first][p.second]) break;
          if (dis[to.first][to.second] > (dis[p.first][p.second] + 1)) {
            dis[to.first][to.second] = dis[p.first][p.second] + 1;
            q.push(to);
          }
        } else
          break;
      }
    }
  }
  cout << -1;
  return 0;
}
