#include <bits/stdc++.h>
using namespace std;
const int MOD = 2000000;
int n, m, k;
int x[MOD], y[MOD], s[MOD];
bool a[2000][2000], v[2000][2000];
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= n; i++) {
    char c;
    scanf("%c", &c);
    for (int j = 1; j <= m; j++) {
      scanf("%c", &c);
      if (c == '.')
        a[i][j] = 0;
      else
        a[i][j] = 1;
    }
  }
  int x1, y1, x2, y2;
  scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
  if (x1 == x2 && y1 == y2) {
    printf("0\n");
    return 0;
  }
  int l = 0, r = 0;
  x[l] = x1;
  y[l] = y1;
  s[l] = 0;
  while (l <= r) {
    v[x[l]][y[l]] = true;
    for (int p = x[l] - 1; p >= 1 && p >= x[l] - k && (!a[p][y[l]]); p--) {
      if (!v[p][y[l]]) {
        r = (r + 1) % MOD;
        x[r] = p;
        y[r] = y[l];
        s[r] = s[l] + 1;
        v[x[r]][y[r]] = true;
        if (x[r] == x2 && y[r] == y2) {
          printf("%d\n", s[r]);
          return 0;
        }
      }
    }
    for (int p = x[l] + 1; p <= n && p <= x[l] + k && (!a[p][y[l]]); p++) {
      if (!v[p][y[l]]) {
        r = (r + 1) % MOD;
        x[r] = p;
        y[r] = y[l];
        s[r] = s[l] + 1;
        v[x[r]][y[r]] = true;
        if (x[r] == x2 && y[r] == y2) {
          printf("%d\n", s[r]);
          return 0;
        }
      }
    }
    for (int q = y[l] - 1; q >= 1 && q >= y[l] - k && (!a[x[l]][q]); q--) {
      if (!v[x[l]][q]) {
        r = (r + 1) % MOD;
        x[r] = x[l];
        y[r] = q;
        s[r] = s[l] + 1;
        v[x[r]][y[r]] = true;
        if (x[r] == x2 && y[r] == y2) {
          printf("%d\n", s[r]);
          return 0;
        }
      }
    }
    for (int q = y[l] + 1; q <= m && q <= y[l] + k && (!a[x[l]][q]); q++) {
      if (!v[x[l]][q]) {
        r = (r + 1) % MOD;
        x[r] = x[l];
        y[r] = q;
        s[r] = s[l] + 1;
        v[x[r]][y[r]] = true;
        if (x[r] == x2 && y[r] == y2) {
          printf("%d\n", s[r]);
          return 0;
        }
      }
    }
    l = (l + 1) % MOD;
  }
  printf("-1\n");
}
