#include <bits/stdc++.h>
using namespace std;
struct Pt {
  long long int x, y, s, d;
  friend ostream& operator<<(ostream& os, Pt p) {
    os << "[" << p.x << "," << p.y << "]";
    return os;
  }
};
int r[1005][1005][2];
int main() {
  ios::sync_with_stdio(false);
  long long int N, M, K;
  cin >> N >> M >> K;
  vector<string> a(N);
  for (long long int i = (0); i < (long long int)(N); ++i) cin >> a[i];
  Pt s, e;
  cin >> s.x >> s.y;
  cin >> e.x >> e.y;
  s.x--;
  s.y--;
  e.x--;
  e.y--;
  s.d = 0;
  for (long long int i = (0); i < (long long int)(1005); ++i)
    for (long long int j = (0); j < (long long int)(1005); ++j)
      r[i][j][0] = r[i][j][1] = 0;
  Pt d[2][2] = {{{1, 0}, {-1, 0}}, {{0, 1}, {0, -1}}};
  queue<Pt> q;
  q.push(s);
  while (!q.empty()) {
    Pt ee = q.front();
    q.pop();
    if (ee.x == e.x && ee.y == e.y) {
      cout << ee.d << endl;
      return 0;
    }
    for (long long int i = (0); i < (long long int)(2); ++i)
      for (long long int j = (0); j < (long long int)(2); ++j) {
        Pt el = ee;
        Pt dx = d[i][j];
        for (int w = 0; w < K; ++w) {
          el.x += dx.x;
          el.y += dx.y;
          if (el.x < 0 || el.x >= N || el.y < 0 || el.y >= M) {
            break;
          }
          if (a[el.x][el.y] == '#' || r[el.x][el.y][i]) {
            break;
          }
          r[el.x][el.y][i] = el.d + 1;
          Pt n = {el.x, el.y, i, el.d + 1};
          q.push(n);
        }
      }
  }
  cout << -1 << endl;
  return 0;
}
