#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1);
const int N = 1e5 + 5;
int n, m, k, dis[1003][1003], dr[] = {0, 0, -1, 1}, dc[] = {1, -1, 0, 0},
                              vis[1003][1003];
char s[1003][1003];
pair<int, int> st, en;
bool valid(int i, int j) {
  return (i < n && j < m && i >= 0 && j >= 0 && s[i][j] != '#' &&
          vis[i][j] < 10);
}
int BFS() {
  memset(dis, -1, sizeof dis);
  dis[st.first][st.second] = 0;
  deque<pair<int, pair<pair<int, int>, pair<int, int>>>> q;
  q.push_back({0, {st, {-1, 0}}});
  while (q.size()) {
    int r = q.front().second.first.first;
    int c = q.front().second.first.second;
    int d = q.front().second.second.first;
    int cnt = q.front().second.second.second;
    int x = q.front().first;
    q.pop_front();
    for (int i = 0; i < 4; i++) {
      int nr = r + dr[i], nc = c + dc[i];
      if (valid(nr, nc)) {
        if (!vis[nr][nc]) dis[nr][nc] = 1e9;
        ++vis[nr][nc];
        if (i == d && cnt != k) {
          q.push_front({x, {{nr, nc}, {d, cnt + 1}}});
          dis[nr][nc] = min(dis[nr][nc], x);
        } else {
          q.push_back({x + 1, {{nr, nc}, {i, 1}}});
          dis[nr][nc] = min(dis[nr][nc], x + 1);
        }
      }
    }
  }
  return dis[en.first][en.second];
}
int main() {
  scanf("%d %d %d", &n, &m, &k);
  for (int i = 0; i < n; i++) scanf("%s", s[i]);
  scanf("%d %d %d %d", &st.first, &st.second, &en.first, &en.second);
  --st.first;
  --st.second;
  --en.first;
  --en.second;
  printf("%d\n", BFS());
  return 0;
}
