#include <bits/stdc++.h>
using namespace std;
const long long M = 1e3 + 7, mod = 1e9 + 7;
long long d[8] = {0, 1, 0, -1, 1, 0, -1, 0};
long long dp[M][M], dp1[M][M];
long long n, m, k;
vector<string> v;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  {
    cin >> n >> m >> k;
    v.push_back("");
    for (long long i = 1; i <= n; i++) {
      string s;
      cin >> s;
      s = "#" + s;
      v.push_back(s);
    }
    memset(dp, -1, sizeof(dp));
    long long a, b, e, f;
    cin >> a >> b >> e >> f;
    queue<pair<long long, long long>> q;
    q.push({a, b});
    dp[a][b] = 0;
    while (!q.empty()) {
      long long r = q.front().first, c = (q.front()).second;
      q.pop();
      for (long long i = r + 1; i <= min(n, r + k); i++) {
        if (v[i][c] == '#') break;
        if (dp[i][c] == -1 || dp[i][c] > dp[r][c] + 1) {
          dp[i][c] = dp[r][c] + 1;
          q.push({i, c});
        } else
          break;
      }
      for (long long i = r - 1; i >= max((long long)1, r - k); i--) {
        if (v[i][c] == '#') break;
        if (dp[i][c] == -1 || dp[i][c] > dp[r][c] + 1) {
          dp[i][c] = dp[r][c] + 1;
          q.push({i, c});
        } else
          break;
      }
      for (long long i = c + 1; i <= min(m, c + k); i++) {
        if (v[r][i] == '#') break;
        if (dp[r][i] == -1 || dp[r][i] > dp[r][c] + 1) {
          dp[r][i] = dp[r][c] + 1;
          q.push({r, i});
        } else
          break;
      }
      for (long long i = c - 1; i >= max((long long)1, c - k); i--) {
        if (v[r][i] == '#') break;
        if (dp[r][i] == -1 || dp[r][i] > dp[r][c] + 1) {
          dp[r][i] = dp[r][c] + 1;
          q.push({r, i});
        } else
          break;
      }
    }
    memset(dp1, -1, sizeof(dp1));
    q.push({a, b});
    dp1[a][b] = 0;
    while (!q.empty()) {
      long long r = q.front().first, c = (q.front()).second;
      q.pop();
      for (long long i = c + 1; i <= min(m, c + k); i++) {
        if (v[r][i] == '#') break;
        if (dp1[r][i] == -1 || dp1[r][i] > dp1[r][c] + 1) {
          dp1[r][i] = dp1[r][c] + 1;
          q.push({r, i});
        } else
          break;
      }
      for (long long i = c - 1; i >= max((long long)1, c - k); i--) {
        if (v[r][i] == '#') break;
        if (dp1[r][i] == -1 || dp1[r][i] > dp1[r][c] + 1) {
          dp1[r][i] = dp1[r][c] + 1;
          q.push({r, i});
        } else
          break;
      }
      for (long long i = r + 1; i <= min(n, r + k); i++) {
        if (v[i][c] == '#') break;
        if (dp1[i][c] == -1 || dp1[i][c] > dp1[r][c] + 1) {
          dp1[i][c] = dp1[r][c] + 1;
          q.push({i, c});
        } else
          break;
      }
      for (long long i = r - 1; i >= max((long long)1, r - k); i--) {
        if (v[i][c] == '#') break;
        if (dp1[i][c] == -1 || dp1[i][c] > dp1[r][c] + 1) {
          dp1[i][c] = dp1[r][c] + 1;
          q.push({i, c});
        } else
          break;
      }
    }
    cout << min(dp[e][f], dp1[e][f]) << "\n";
  }
  return 0;
}
