#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1e9 + 7;
const long long int INF = 1000111000111000111LL;
const long long int MAX = 1001713;
char a[1001 + 2][1001 + 2];
long long int dp[1003][1003];
bool visited[1003][1003];
int32_t main() {
  long long int n, m, k;
  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];
  for (long long int i = 0; i <= n + 1; i++) a[i][0] = '#';
  for (long long int i = 0; i <= n + 1; i++) a[i][m + 1] = '#';
  for (long long int i = 0; i <= m + 1; i++) a[0][i] = '#';
  for (long long int i = 0; i <= m + 1; i++) a[n + 1][i] = '#';
  for (long long int i = 0; i <= n + 1; i++) {
    for (long long int j = 0; j <= m + 1; j++) {
      dp[i][j] = INF;
    }
  }
  memset(visited, false, sizeof visited);
  long long int sx, sy, ex, ey;
  cin >> sx >> sy >> ex >> ey;
  visited[sx][sy] = true;
  dp[sx][sy] = 0;
  queue<pair<long long int, long long int> > pq;
  pq.push({sx, sy});
  while (!pq.empty()) {
    long long int x = pq.front().first;
    long long int y = pq.front().second;
    pq.pop();
    visited[x][y] = true;
    long long int d = 0;
    for (long long int i = x - 1;
         i >= 1 && d < k && a[i][y] == '.' && dp[i][y] >= dp[x][y] + 1; --i) {
      if (!visited[i][y]) {
        visited[i][y] = true;
        pq.push({i, y});
        dp[i][y] = min(dp[i][y], dp[x][y] + 1);
      }
      d++;
    }
    d = 0;
    for (long long int i = x + 1;
         i <= n && d < k && a[i][y] == '.' && dp[i][y] >= dp[x][y] + 1; ++i) {
      if (!visited[i][y]) {
        visited[i][y] = true;
        pq.push({i, y});
        dp[i][y] = min(dp[i][y], dp[x][y] + 1);
      }
      d++;
    }
    d = 0;
    for (long long int i = y + 1;
         i <= m && d < k && a[x][i] == '.' && dp[x][i] >= dp[x][y] + 1; ++i) {
      if (!visited[x][i]) {
        visited[x][i] = true;
        pq.push({x, i});
        dp[x][i] = min(dp[x][i], dp[x][y] + 1);
      }
      d++;
    }
    d = 0;
    for (long long int i = y - 1;
         i >= 1 && d < k && a[x][i] == '.' && dp[x][i] >= dp[x][y] + 1; --i) {
      if (!visited[x][i]) {
        visited[x][i] = true;
        pq.push({x, i});
        dp[x][i] = min(dp[x][i], dp[x][y] + 1);
      }
      d++;
    }
  }
  if (dp[ex][ey] == INF) {
    return cout << -1, 0;
  }
  cout << dp[ex][ey];
  return 0;
}
