#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int h, w, k;
  cin >> h >> w >> k;
  ++k;
  vector<vector<char>> rec(h, vector<char>(w));
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      cin >> rec[i][j];
    }
  }
  int xb, yb, xe, ye;
  cin >> xb >> yb >> xe >> ye;
  --xb;
  --yb;
  --xe;
  --ye;
  vector<vector<int>> dis(h, vector<int>(w, 1 << 30));
  int dx[4] = {0, 0, -1, 1};
  int dy[4] = {1, -1, 0, 0};
  queue<vector<int>> que;
  que.push({xb, yb});
  dis[xb][yb] = 0;
  while (!que.empty()) {
    int x = que.front()[0], y = que.front()[1];
    que.pop();
    for (int r = 0; r < 4; ++r) {
      int u = x, v = y, s = dis[x][y] + 1;
      for (int d = 1; d < k; ++d) {
        u += dx[r];
        v += dy[r];
        if (0 <= u && u < h && 0 <= v && v < w && rec[u][v] == '.') {
          if (dis[u][v] > s) {
            dis[u][v] = s;
            que.push({u, v});
          } else if (dis[u][v] < s) {
            break;
          }
        } else {
          break;
        }
      }
    }
  }
  if (dis[xe][ye] == 1 << 30) {
    cout << -1 << endl;
  } else {
    cout << dis[xe][ye] << endl;
  }
  return 0;
}
