#include <bits/stdc++.h>
using namespace std;
int n, m, i, j, o, p, k, x, y, dd, x1, b[1000 + 5][1000 + 5], dfjghd, x2, y2,
    d[1000 + 5][1000 + 5];
char a[1000 + 5][1000 + 5];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m >> k;
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++) {
      cin >> a[i][j];
      d[i][j] = INT_MAX;
    }
  queue<pair<int, int> > s;
  cin >> x1 >> dfjghd >> x2 >> y2;
  d[x1][dfjghd] = 0;
  s.push({x1, dfjghd});
  while (!s.empty()) {
    x = s.front().first;
    y = s.front().second;
    s.pop();
    b[x][y] = 0;
    dd = 0;
    for (j = y + 1; j <= m; j++) {
      if (a[x][j] == '#' || (d[x][j] < d[x][y] + 1)) break;
      dd++;
      if (dd > k) break;
      if (d[x][j] > d[x][y] + 1) {
        d[x][j] = d[x][y] + 1;
        if (b[x][j] == 0) {
          b[x][j] = 1;
          s.push({x, j});
        }
      }
    }
    dd = 0;
    for (i = x + 1; i <= n; i++) {
      if (a[i][y] == '#' || (d[i][y] < d[x][y] + 1)) break;
      dd++;
      if (dd > k) break;
      if (d[i][y] >= d[x][y] + 1) {
        d[i][y] = d[x][y] + 1;
        if (b[i][y] == 0) {
          b[i][y] = 1;
          s.push({i, y});
        }
      }
    }
    dd = 0;
    for (j = y - 1; j >= 1; j--) {
      if (a[x][j] == '#' || (d[x][j] < d[x][y] + 1)) break;
      dd++;
      if (dd > k) break;
      if (d[x][j] > d[x][y] + 1) {
        d[x][j] = d[x][y] + 1;
        if (b[x][j] == 0) {
          b[x][j] = 1;
          s.push({x, j});
        }
      }
    }
    dd = 0;
    for (i = x - 1; i >= 1; i--) {
      if (a[i][y] == '#' || (d[i][y] < d[x][y] + 1)) break;
      dd++;
      if (dd > k) break;
      if (d[i][y] > d[x][y] + 1) {
        d[i][y] = d[x][y] + 1;
        if (b[i][y] == 0) {
          b[i][y] = 1;
          s.push({i, y});
        }
      }
    }
  }
  if (d[x2][y2] == INT_MAX)
    cout << -1;
  else
    cout << d[x2][y2];
}
