#include <bits/stdc++.h>
using namespace std;
int han[4] = {0, 0, 1, -1}, lie[4] = {1, -1, 0, 0};
int n, m, number[1010][1010], k;
int step[1010][1010];
int stx, sty, lenx, leny;
void bfs() {
  queue<pair<int, int> > str;
  str.push(make_pair(stx, sty));
  memset(step, -1, sizeof(step));
  step[stx][sty] = 0;
  while (str.size()) {
    pair<int, int> now = str.front();
    str.pop();
    for (int a = 0; a < 4; a++) {
      for (int b = 1; b <= k; b++) {
        int han1 = now.first + han[a] * b;
        int lie1 = now.second + lie[a] * b;
        if (han1 <= 0 || lie1 <= 0 || han1 > n || lie1 > m) break;
        if (number[han1][lie1] == 1) break;
        if ((step[han1][lie1] != -1) &&
            (step[han1][lie1] < step[now.first][now.second] + 1))
          break;
        if (step[han1][lie1] == -1) {
          step[han1][lie1] = step[now.first][now.second] + 1;
          if (han1 == lenx && lie1 == leny) {
            cout << step[han1][lie1] << endl;
            return;
          }
          str.push(make_pair(han1, lie1));
        }
      }
    }
  }
  cout << "-1" << endl;
  return;
}
int main() {
  ios::sync_with_stdio(0);
  cin >> n >> m >> k;
  char c;
  for (int a = 1; a <= n; a++)
    for (int b = 1; b <= m; b++) {
      cin >> c;
      if (c == '.')
        number[a][b] = 0;
      else
        number[a][b] = 1;
    }
  cin >> stx >> sty >> lenx >> leny;
  if (stx == lenx && sty == leny) {
    cout << "0" << endl;
    return 0;
  }
  bfs();
  return 0;
}
