#include <bits/stdc++.h>
using namespace std;
int n, m, k;
char mat[1002][1002];
int mincost[1002][1002];
deque<pair<int, int> > d;
int xa, ya, xb, yb;
bool viz[1002][1002];
int ox[] = {-1, 0, 1, 0};
int oy[] = {0, 1, 0, -1};
bool gut(int L, int C) {
  if (!L || L > n) return 0;
  if (!C || C > m) return 0;
  return 1;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> m >> k;
  for (int i = 1; i <= n; ++i) cin >> mat[i] + 1;
  cin >> xa >> ya >> xb >> yb;
  viz[xa][ya] = 1;
  d.push_back({xa, ya});
  while (!d.empty() && !viz[xb][yb]) {
    int L = d[0].first;
    int C = d[0].second;
    d.pop_front();
    for (int i = 0; i <= 3; ++i)
      for (int j = 1; gut(L + j * ox[i], C + j * oy[i]) && j <= k; ++j)
        if (!viz[L + j * ox[i]][C + j * oy[i]] &&
            mat[L + j * ox[i]][C + j * oy[i]] != '#') {
          mincost[L + j * ox[i]][C + j * oy[i]] = mincost[L][C] + 1;
          viz[L + j * ox[i]][C + j * oy[i]] = 1;
          d.push_back({L + j * ox[i], C + j * oy[i]});
        } else if (mat[L + j * ox[i]][C + j * oy[i]] == '#')
          break;
  }
  if (!viz[xb][yb])
    cout << -1;
  else
    cout << mincost[xb][yb] << '\n';
  return 0;
}
