#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1e3 + 10;
const int MOD = 1e9 + 7;
int n, m, k, xaval, yaval, xakhar, yakhar, dx, dy;
int d[MAX_N][MAX_N];
char ch[MAX_N][MAX_N];
bool seen[MAX_N][MAX_N], mark[MAX_N][MAX_N][5];
int xMove[4] = {0, 0, -1, 1};
int yMove[4] = {-1, 1, 0, 0};
queue<pair<int, int> > q;
void Init() {
  cin >> n >> m >> k;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) cin >> ch[i][j];
  return;
}
void AddToQueue(int x, int y, int counter) {
  for (int i = 0; i < 4; i++) {
    for (int j = 1; j < k + 1; j++) {
      dx = x + (xMove[i] * j);
      dy = y + (yMove[i] * j);
      if (dx < 0 || dy < 0 || dx >= n || dy >= m) break;
      if (ch[dx][dy] != '.' || mark[dx][dy][i]) break;
      mark[dx][dy][i] = 1;
      if (!seen[dx][dy]) {
        seen[dx][dy] = 1;
        d[dx][dy] = counter + 1;
        q.push({dx, dy});
      }
    }
  }
  return;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ;
  Init();
  cin >> xaval >> yaval >> xakhar >> yakhar;
  xaval--;
  yaval--;
  xakhar--;
  yakhar--;
  q.push({xaval, yaval});
  d[xaval][yaval] = 0;
  seen[xaval][yaval] = 1;
  pair<int, int> now;
  while (!q.empty()) {
    now = q.front();
    q.pop();
    AddToQueue(now.first, now.second, d[now.first][now.second]);
    if (now.first == xakhar && now.second == yakhar) break;
  }
  if (xaval == xakhar && yaval == yakhar)
    cout << 0 << "\n";
  else if (d[xakhar][yakhar] == 0)
    cout << -1 << "\n";
  else
    cout << d[xakhar][yakhar] << "\n";
}
