#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T poww(T b, T p) {
  long long a = 1;
  while (p) {
    if (p & 1) {
      a = (a * b);
    }
    p >>= 1;
    b = (b * b);
  }
  return a;
}
template <class T>
inline T gcd(T a, T b) {
  if (b > a) return gcd(b, a);
  return ((b == 0) ? a : gcd(b, a % b));
}
template <class T>
inline T modpoww(T b, T p, T modd) {
  long long a = 1;
  while (p) {
    if (p & 1) {
      a = (a * b) % modd;
    }
    p >>= 1;
    b = (b * b) % modd;
  }
  return a % modd;
}
struct point {
  int x, y;
};
ostream& operator<<(ostream& os, const point& p) {
  os << "Point is: " << p.x << "," << p.y << ":\n";
  return os;
}
int n, m;
std::vector<string> b;
int dirx[] = {1, -1, 0, 0};
int diry[] = {0, 0, 1, -1};
int fl[1001][1001];
int dd[1001][1001];
inline bool isvalid(point p) {
  int x = p.x, y = p.y;
  if (x < 0 || x >= n || y < 0 || y >= m) return false;
  return true;
}
int main() {
  int i, j, k;
  int a, bb, c, d;
  cin >> n >> m >> k;
  string s;
  for ((i) = 0; (i) < (n); (i)++) {
    cin >> s;
    b.push_back(s);
  }
  cin >> a >> bb >> c >> d;
  a--, bb--, c--, d--;
  memset(dd, -1, sizeof(dd));
  queue<pair<int, point> > q;
  q.push(make_pair(0, (point){a, bb}));
  fl[a][bb] = 1;
  dd[a][bb] = 0;
  int ans = -1;
  int dist;
  point p;
  while (q.size()) {
    dist = q.front().first;
    p = q.front().second;
    q.pop();
    if (p.x == c && p.y == d) {
      ans = dist;
      break;
    }
    for ((i) = 0; (i) < (4); (i)++) {
      for ((j) = (1); (j) < (k + 1); (j) += 1) {
        point pt = (point){p.x + dirx[i] * j, p.y + diry[i] * j};
        if (isvalid(pt) && b[pt.x][pt.y] != '#') {
          if (fl[pt.x][pt.y]) {
            if (dd[pt.x][pt.y] == dd[p.x][p.y])
              break;
            else
              continue;
          }
          fl[pt.x][pt.y] = 1;
          dd[pt.x][pt.y] = dist + 1;
          q.push(make_pair(dist + 1, pt));
        } else {
          break;
        }
      }
    }
  }
  cout << ans << "\n";
}
