#include <bits/stdc++.h>
using namespace std;
long long begtime = clock();
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cout << name << " : " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
void splitx(string s, char c, vector<string>& v) {
  long long i = 0, j;
  while (i < (long long)(s).size()) {
    j = i;
    string temp;
    while (j < (long long)(s).size() && s[j] != c) {
      temp += s[j];
      j++;
    }
    v.push_back(temp);
    i = j + 1;
  }
}
vector<long long> dx{1, 0, -1, 0, 1, 1, -1, -1};
vector<long long> dy{0, 1, 0, -1, 1, -1, 1, -1};
signed main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, m, k;
  cin >> n >> m >> k;
  vector<string> v(n);
  for (long long i = 0; i < n; i++) {
    cin >> v[i];
  }
  vector<vector<long long> > vis(n, vector<long long>(m, 0));
  vector<vector<long long> > dist(n, vector<long long>(m, 1000000000000000007));
  long long x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  x1--;
  y1--;
  x2--;
  y2--;
  queue<pair<long long, long long> > q;
  q.push({x1, y1});
  dist[x1][y1] = 0;
  while (!q.empty()) {
    pair<long long, long long> p = q.front();
    q.pop();
    long long x = p.first;
    long long y = p.second;
    if (vis[x][y]) continue;
    vis[x][y] = 1;
    for (long long i = 0; i < 4; i++) {
      for (long long j = 1; j < k + 1; j++) {
        long long nx = x + dx[i] * j;
        long long ny = y + dy[i] * j;
        if (nx < 0 || nx >= n || ny < 0 || ny >= m) break;
        if (v[nx][ny] == '#' || dist[nx][ny] < dist[x][y] + 1) break;
        dist[nx][ny] = dist[x][y] + 1;
        q.push({nx, ny});
      }
    }
  }
  if (dist[x2][y2] == 1000000000000000007) {
    cout << -1 << '\n';
  } else {
    cout << dist[x2][y2] << '\n';
  }
  return 0;
}
