#include <bits/stdc++.h>
using namespace std;
vector<string> st;
int dp[1001][1001];
int sta[1001][1001];
void djkstra(int n, int m, int x1, int y1, int x2, int y2, int k) {
  priority_queue<pair<int, pair<int, int> >,
                 vector<pair<int, pair<int, int> > >,
                 greater<pair<int, pair<int, int> > > >
      pq;
  pq.push(make_pair(0, make_pair(x1, y1)));
  int co = 0;
  while (co <= (n * m) && !pq.empty()) {
    pair<int, pair<int, int> > x;
    x = pq.top();
    pq.pop();
    if (x.first == 1e9) break;
    if (sta[x.second.first][x.second.second]) continue;
    sta[x.second.first][x.second.second] = 1;
    dp[x.second.first][x.second.second] = x.first;
    co++;
    int u = x.second.first;
    int v = x.second.second;
    int fl = 0;
    for (int f = 0; f < 4; f++) {
      fl = 0;
      int o = v;
      int r = u;
      for (int i = 0; i < k; i++) {
        if (f == 0) o++;
        if (f == 1) o--;
        if (f == 2) r++;
        if (f == 3) r--;
        if (r >= 0 && o >= 0 && r < n && o < (m) && (st[r][o] == '.') &&
            (dp[r][o] >= dp[u][v] + 1)) {
          if (dp[r][o] > dp[u][v] + 1) {
            dp[r][o] = dp[u][v] + 1;
            pq.push(make_pair(dp[r][o], make_pair(r, o)));
          }
        } else {
          fl = 1;
          break;
        }
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  int i, j;
  int n, m, k;
  cin >> n >> m >> k;
  for (i = 0; i < 1000; i++)
    for (j = 0; j < 1000; j++) dp[i][j] = 1e9;
  for (i = 0; i < n; i++) {
    string x;
    cin >> x;
    st.push_back(x);
  }
  int x1, x2, y1, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  djkstra(n, m, x1 - 1, y1 - 1, x2 - 1, y2 - 1, k);
  if (dp[x2 - 1][y2 - 1] == 1e9)
    cout << -1 << endl;
  else
    cout << dp[x2 - 1][y2 - 1] << endl;
  return 0;
}
