#include <bits/stdc++.h>
using namespace std;
const int SIZE = 1 << 10;
int pointer = SIZE;
char buffer[SIZE];
inline char readchar() {
  if (pointer == SIZE) {
    fread(buffer, 1, SIZE, stdin);
    pointer = 0;
  }
  return buffer[pointer++];
}
inline void out(int x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) out(x / 10);
  putchar(x % 10 + '0');
}
const int N = 1010;
int m, n, k;
int xs, ys, xt, yt;
int a[N][N];
int d[] = {-1, 0, 1, 0};
int c[] = {0, 1, 0, -1};
pair<int, int> f[N][N][5];
struct id {
  int x, y, o;
};
deque<id> q;
int main() {
  m = ({
    int x = 0;
    int c = readchar(), n = 0;
    for (; !isdigit(c); c = readchar()) n = (c == '-');
    for (; isdigit(c); c = readchar()) x = x * 10 + c - '0';
    n ? -x : x;
  }),
  n = ({
    int x = 0;
    int c = readchar(), n = 0;
    for (; !isdigit(c); c = readchar()) n = (c == '-');
    for (; isdigit(c); c = readchar()) x = x * 10 + c - '0';
    n ? -x : x;
  }),
  k = ({
    int x = 0;
    int c = readchar(), n = 0;
    for (; !isdigit(c); c = readchar()) n = (c == '-');
    for (; isdigit(c); c = readchar()) x = x * 10 + c - '0';
    n ? -x : x;
  });
  for (int i = 1; i <= m; ++i) {
    for (int j = 1; j <= n; ++j) {
      char ch = readchar();
      while (ch != '.' && ch != '#') ch = readchar();
      a[i][j] = ch == '#';
    }
  }
  xs = ({
    int x = 0;
    int c = readchar(), n = 0;
    for (; !isdigit(c); c = readchar()) n = (c == '-');
    for (; isdigit(c); c = readchar()) x = x * 10 + c - '0';
    n ? -x : x;
  }),
  ys = ({
    int x = 0;
    int c = readchar(), n = 0;
    for (; !isdigit(c); c = readchar()) n = (c == '-');
    for (; isdigit(c); c = readchar()) x = x * 10 + c - '0';
    n ? -x : x;
  }),
  xt = ({
    int x = 0;
    int c = readchar(), n = 0;
    for (; !isdigit(c); c = readchar()) n = (c == '-');
    for (; isdigit(c); c = readchar()) x = x * 10 + c - '0';
    n ? -x : x;
  }),
  yt = ({
    int x = 0;
    int c = readchar(), n = 0;
    for (; !isdigit(c); c = readchar()) n = (c == '-');
    for (; isdigit(c); c = readchar()) x = x * 10 + c - '0';
    n ? -x : x;
  });
  if (xs == xt && ys == yt) return out(0), 0;
  if (a[xs][ys] || a[xt][yt]) return out(-1), 0;
  int sz = 0;
  q.push_back({xs, ys, 4});
  f[xs][ys][4] = {0, 0};
  pair<int, int> nil = {0, 0};
  while (q.size()) {
    int x, y, o;
    id fo = q.front();
    q.pop_front();
    x = fo.x, y = fo.y, o = fo.o;
    sz++;
    pair<int, int> &cur = f[x][y][o];
    if (x == xt && y == yt) {
      return out(cur.first), 0;
    }
    for (int i = 0; i < 4; ++i) {
      int u, v, h, g;
      u = x + d[i], v = y + c[i], h = (i == o ? cur.second + 1 : 1),
      g = (h > k ? 1 : h);
      pair<int, int> nxt = {cur.first + (i != o) + (h > k), g};
      if (1 > u || u > m || 1 > v || v > n || a[u][v] ||
          (f[u][v][i] <= nxt && f[u][v][i] != nil))
        continue;
      f[u][v][i] = nxt;
      if (i == o)
        q.push_front({u, v, i});
      else
        q.push_back({u, v, i});
    }
  }
  out(-1);
}
