#include <bits/stdc++.h>
using vi = std::vector<long long int>;
using vvi = std::vector<vi>;
using pii = std::pair<long long int, long long int>;
using vpii = std::vector<pii>;
using vvpii = std::vector<vpii>;
using namespace std;
const long long int N = 1e3 + 10;
const long long int inf = 1e18 + 10;
const long double Pi = 3.14159265;
char a[N][N];
long long int n, m, k, vis[N][N], sx, sy, tx, ty;
queue<pii> q;
long long int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
void solve() {
  cin >> n >> m >> k;
  for (long long int i = 1; i <= n; i++)
    for (long long int j = 1; j <= m; j++) {
      cin >> a[i][j];
      if (a[i][j] == '#')
        vis[i][j] = -inf;
      else
        vis[i][j] = inf;
    }
  cin >> sx >> sy >> tx >> ty;
  q.push(pii{sx, sy});
  vis[sx][sy] = 0;
  long long int taka = 0;
  while (q.empty() == 0) {
    long long int z = (long long int)q.size();
    while (z-- != 0) {
      long long int x = (q.front()).first, y = (q.front().second);
      q.pop();
      if (vis[x][y] == -inf) continue;
      if (pii{x, y} == pii{tx, ty}) {
        cout << taka;
        return;
      }
      for (long long int d = 0; d <= 3; d++) {
        for (long long int i = 1; i <= k; i++) {
          long long int X = x + dx[d] * i;
          long long int Y = y + dy[d] * i;
          if (X < 1 or X > n or Y < 1 or Y > m or vis[X][Y] == -inf) break;
          if (vis[X][Y] <= vis[x][y]) break;
          if (vis[X][Y] <= 1 + vis[x][y]) continue;
          vis[X][Y] = 1 + vis[x][y];
          q.push(pii{X, Y});
        }
      }
    }
    taka++;
  }
  cout << -1;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  solve();
  return 0;
  long long int xx = 0;
  long long int t;
  cin >> t;
  while (t--) {
    ;
    solve();
    cout << endl;
  }
  return 0;
}
