#include <bits/stdc++.h>
using namespace std;
int dis[1001][1001] = {0};
int r, c;
bool found[1001][1001] = {false};
bool range(int x, int y) {
  if (x >= 0 && x < r && y >= 0 && y < c) return true;
  return false;
}
int pos_x[] = {1, -1, 0, 0};
int pos_y[] = {0, 0, 1, -1};
char str[1011][1011];
int main() {
  int i, j, k, si, sj, ei, ej;
  cin >> r >> c >> k;
  memset(dis, 33, sizeof(dis));
  for (i = 1; i <= r; ++i) scanf("%s", str[i] + 1);
  cin >> si >> sj >> ei >> ej;
  queue<pair<int, int> > q;
  q.push(make_pair(si, sj));
  dis[si][sj] = 0;
  while (!q.empty()) {
    int u = q.front().first;
    int v = q.front().second;
    q.pop();
    if (u == ei && v == ej) {
      cout << dis[u][v];
      return 0;
    }
    for (i = 0; i < 4; ++i) {
      for (j = 1; j <= k; ++j) {
        int x = u + pos_x[i] * j;
        int y = v + pos_y[i] * j;
        if (str[x][y] != '.' || dis[x][y] <= dis[u][v]) break;
        if (dis[x][y] > dis[u][v] + 1) {
          dis[x][y] = dis[u][v] + 1;
          q.push(make_pair(x, y));
        }
      }
    }
  }
  cout << "-1";
  return 0;
}
