#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
int dcmp(double x) {
  if (fabs(x) < eps) return 0;
  return (x > 0) ? 1 : -1;
}
const unsigned long long hash1 = 201326611;
const unsigned long long hash2 = 50331653;
const int N = 1000000 + 10;
const int M = 1000 + 10;
const int inf = 0x3f3f3f3f;
const long long mod = 1000000000 + 7;
int n, m, k, sx, sy, ex, ey;
char mp[M][M];
int vis[M][M], dis[M][M];
int dx[4] = {0, 0, 1, -1}, dy[4] = {1, -1, 0, 0};
struct node {
  int x, y;
};
int check(int tx, int ty) {
  if (tx < 1 || tx > n || ty < 1 || ty > m) return 0;
  if (mp[tx][ty] == '#') return 0;
  return 1;
}
int bfs() {
  queue<pair<int, int> > qu;
  qu.push(make_pair(sx, sy));
  vis[sx][sy] = (1 << 4) - 1;
  dis[sx][sy] = 0;
  while (!qu.empty()) {
    pair<int, int> now = qu.front();
    qu.pop();
    if (now.first == ex && now.second == ey) return dis[ex][ey];
    for (int i = 0; i < 4; i++) {
      int tmp = k, tx = now.first, ty = now.second;
      while (tmp--) {
        tx += dx[i], ty += dy[i];
        if (!check(tx, ty)) break;
        if ((vis[tx][ty] >> i) & 1) break;
        vis[tx][ty] |= (1 << i);
        if (dis[tx][ty] != 0)
          dis[tx][ty] = min(dis[tx][ty], dis[now.first][now.second] + 1);
        else
          dis[tx][ty] = dis[now.first][now.second] + 1;
        qu.push(make_pair(tx, ty));
      }
    }
  }
  return -1;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++) {
    cin >> mp[i] + 1;
  }
  cin >> sx >> sy >> ex >> ey;
  cout << bfs() << endl;
  return 0;
}
