#include <bits/stdc++.h>
using namespace std;
int n, m, k, x, y, xx, yy;
int mx[] = {0, -1, 0, 1}, my[] = {1, 0, -1, 0};
int dis[1005][1005];
char s[1005][1005];
queue<pair<int, int> > q;
int main() {
  scanf("%d %d %d ", &n, &m, &k);
  for (int i = 1; i <= n; i++) gets(s[i] + 1);
  for (int i = 0; i <= m + 1; i++) s[0][i] = s[n + 1][i] = '#';
  for (int i = 0; i <= n + 1; i++) s[i][0] = s[i][m + 1] = '#';
  scanf("%d %d %d %d", &x, &y, &xx, &yy);
  pair<int, int> src = pair<int, int>(x, y), dst = pair<int, int>(xx, yy);
  for (int i = 0; i <= n + 1; i++)
    for (int j = 1; j <= m + 1; j++) dis[i][j] = 1000000000;
  dis[x][y] = 0;
  q.push(src);
  while (!q.empty()) {
    pair<int, int> now = q.front();
    q.pop();
    for (int i = 0; i < 4; i++) {
      for (int j = 1; j <= k; j++) {
        int nx = now.first + mx[i] * j, ny = now.second + my[i] * j;
        if (s[nx][ny] == '#' || dis[nx][ny] <= dis[now.first][now.second])
          break;
        if (dis[nx][ny] > dis[now.first][now.second] + 1) {
          dis[nx][ny] = dis[now.first][now.second] + 1;
          q.push(pair<int, int>(nx, ny));
        }
      }
    }
  }
  if (dis[xx][yy] == 1000000000)
    printf("-1\n");
  else
    printf("%d\n", dis[xx][yy]);
}
