#include <bits/stdc++.h>
using namespace std;
const int N = 1010;
char g[N][N];
int cost[N][N];
int dr[4] = {0, 0, 1, -1};
int dc[4] = {1, -1, 0, 0};
int n, m, k;
pair<int, int> per[N][N];
int tarx, tary;
int sx, sy;
int getAns() {
  pair<int, int> at = pair<int, int>({tarx, tary});
  bool chx = 0;
  bool chy = 0;
  int c = 0;
  int ans = 0;
  while (1) {
    int perx = per[at.first][at.second].first;
    int pery = per[at.first][at.second].second;
    if (perx == -1 && pery == -1) break;
    if (at.first == perx && at.second != pery) {
      if (!chy) {
        chy = 1;
        ans += ceil((double)c / k);
        c = 0;
      }
      chx = 0;
    } else {
      if (!chx) {
        chx = 1;
        ans += ceil((double)c / k);
        c = 0;
      }
      chy = 0;
    }
    c++;
    at = per[at.first][at.second];
  }
  ans += ceil((double)(c) / k);
  return ans;
}
void dfs(int x, int y) {
  for (int i = 0; i < 4; ++i) {
    int nr = x + dr[i];
    int nc = y + dc[i];
    if (nr >= n || nc >= m || nr < 0 || nc < 0 || g[nr][nc] == '#' ||
        cost[nr][nc] != -1)
      continue;
    cost[nr][nc] = cost[x][y] + 1;
    per[nr][nc] = pair<int, int>(x, y);
    dfs(nr, nc);
  }
}
void bfs() {
  memset(cost, -1, sizeof cost);
  memset(per, -1, sizeof per);
  cost[sx][sy] = 0;
  queue<pair<int, int>> q;
  q.push({sx, sy});
  while (!q.empty()) {
    pair<int, int> t = q.front();
    q.pop();
    for (int i = 0; i < 4; ++i) {
      int nr = t.first + dr[i];
      int nc = t.second + dc[i];
      if (nr >= n || nc >= m || nr < 0 || nc < 0 || g[nr][nc] == '#' ||
          cost[nr][nc] != -1)
        continue;
      cost[nr][nc] = 1 + cost[t.first][t.second];
      per[nr][nc] = t;
      q.push({nr, nc});
      if (nr == tarx && nc == tary) {
        return;
      }
    }
  }
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      scanf(" %c", &g[i][j]);
    }
  }
  scanf("%d%d", &sx, &sy);
  sx--;
  sy--;
  scanf("%d%d", &tarx, &tary);
  tarx--;
  tary--;
  int ans = 1e8;
  bfs();
  ans = min(ans, getAns());
  swap(dr[0], dr[1]);
  swap(dc[0], dc[1]);
  bfs();
  ans = min(ans, getAns());
  swap(dr[0], dr[2]);
  swap(dc[0], dc[2]);
  bfs();
  ans = min(ans, getAns());
  swap(dr[0], dr[3]);
  swap(dc[0], dc[3]);
  bfs();
  ans = min(ans, getAns());
  if (sx == tarx && sy == tary) {
    cout << 0;
    return 0;
  }
  if (ans == 0) {
    cout << -1;
  } else {
    cout << ans;
  }
  return 0;
}
