#include <bits/stdc++.h>
using namespace std;
string s[1001];
bool vis[1001][1001];
int dist[1001][1001];
int n, m, k;
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
bool isv(int x, int y) {
  return (x >= 0 && y >= 0 && x < n && y < m && s[x][y] == '.');
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m >> k;
  for (int i = 0; i < n; i++) cin >> s[i];
  int xi, yi, xf, yf;
  cin >> xi >> yi >> xf >> yf;
  xi--, yi--, xf--, yf--;
  vis[xi][yi] = 1;
  queue<pair<int, int> > q;
  q.push({xi, yi});
  while (!q.empty()) {
    int x = q.front().first, y = q.front().second;
    q.pop();
    for (int i = 0; i < 4; i++) {
      for (int mul = 1; mul <= k; mul++) {
        if (!isv(x + mul * dx[i], y + mul * dy[i])) break;
        if (vis[x + mul * dx[i]][y + mul * dy[i]] &&
            dist[x + mul * dx[i]][y + mul * dy[i]] == 1 + dist[x][y])
          continue;
        if (vis[x + mul * dx[i]][y + mul * dy[i]] &&
            dist[x + mul * dx[i]][y + mul * dy[i]] <= 1 + dist[x][y])
          break;
        vis[x + mul * dx[i]][y + mul * dy[i]] = 1;
        dist[x + mul * dx[i]][y + mul * dy[i]] = dist[x][y] + 1;
        q.push({x + mul * dx[i], y + mul * dy[i]});
      }
    }
  }
  if (vis[xf][yf])
    cout << dist[xf][yf] << '\n';
  else
    cout << "-1\n";
  return 0;
}
