#include <bits/stdc++.h>
using namespace std;
int n, m, k, sr, sc, dr, dc;
string arr[1005];
long long dist[1005][1005];
const int dx[] = {0, 0, 1, -1};
const int dy[] = {1, -1, 0, 0};
bool isValid(int i, int j) {
  if (i < 0 || j < 0 || i >= n || j >= m || arr[i][j] == '#') return false;
  return true;
}
void solve() {
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      dist[i][j] = INT_MAX;
    }
  }
  dist[sr][sc] = 0;
  queue<pair<int, int> > q;
  q.push({sr, sc});
  while (!q.empty()) {
    pair<int, int> front = q.front();
    q.pop();
    int old_x = front.first;
    int old_y = front.second;
    long long parent_dist = dist[old_x][old_y];
    for (int i = 0; i < 4; i++) {
      for (int j = 1; j <= k; j++) {
        int new_x = old_x + (dx[i] * j);
        int new_y = old_y + (dy[i] * j);
        if (!isValid(new_x, new_y)) break;
        assert(new_x < n && new_y < m);
        if (dist[new_x][new_y] > parent_dist + 1) {
          dist[new_x][new_y] = parent_dist + 1;
          q.push({new_x, new_y});
          if (new_x == dr && new_y == dc) {
            cout << dist[new_x][new_y] << endl;
            return;
          }
        }
      }
    }
  }
  if (dist[dr][dc] == INT_MAX) {
    cout << "-1\n";
  } else
    cout << dist[dr][dc] << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  cin >> n >> m >> k;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  cin >> sr >> sc >> dr >> dc;
  sr--;
  sc--;
  dr--;
  dc--;
  solve();
  return 0;
}
