#include <bits/stdc++.h>
using namespace std;
int i, j, k, z, t, n, m, sum, ans, x, y, x2, y2, maxm = 0, minm = INT_MAX;
bool flag;
pair<int, int> vis[4][1005][1005];
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
char a[1005][1005];
bool check(int x, int y) {
  if (x < 1 || x > n || y < 1 || y > m)
    return false;
  else if (a[x][y] == '#')
    return false;
  else
    return true;
}
int bfs(int x, int y) {
  priority_queue<pair<int, pair<pair<int, int>, pair<int, int>>>,
                 vector<pair<int, pair<pair<int, int>, pair<int, int>>>>,
                 greater<pair<int, pair<pair<int, int>, pair<int, int>>>>>
      Q;
  if (x == x2 and y == y2) return 0;
  Q.push({0, {{x, y}, {0, k}}});
  for (int i = 0; i < 4; i++) vis[i][x][y] = {1, k};
  while (!Q.empty()) {
    auto c = Q.top();
    Q.pop();
    int val = c.first;
    x = c.second.first.first;
    y = c.second.first.second;
    int dir = c.second.second.first;
    int lim = c.second.second.second;
    if (x == x2 and y == y2) return val;
    if (vis[dir][x][y] < make_pair(val, lim)) continue;
    if (lim == k) {
      for (int i = 0; i < 4; i++)
        if (check(x + dx[i], y + dy[i]))
          if (vis[i][x + dx[i]][y + dy[i]] > make_pair(val + 1, int(1)))
            vis[i][x + dx[i]][y + dy[i]] = make_pair(val + 1, int(1)),
                                  Q.push(
                                      {val + 1,
                                       {{x + dx[i], y + dy[i]}, {i, int(1)}}});
    } else {
      for (int i = 0; i < 4; i++)
        if (check(x + dx[i], y + dy[i]))
          if (i == dir) {
            if (vis[i][x + dx[i]][y + dy[i]] > make_pair(val, lim + 1))
              vis[i][x + dx[i]][y + dy[i]] = make_pair(val, lim + 1),
                                    Q.push({val,
                                            {{x + dx[i], y + dy[i]},
                                             {i, lim + 1}}});
          } else if (vis[i][x + dx[i]][y + dy[i]] > make_pair(val + 1, int(1)))
            vis[i][x + dx[i]][y + dy[i]] = make_pair(val + 1, int(1)),
                                  Q.push({val + 1,
                                          {{x + dx[i], y + dy[i]}, {i, 1}}});
    }
  }
  for (int i = 0; i < 4; i++) minm = min(minm, vis[i][x2][y2].first);
  if (minm == INT_MAX) minm = -1;
  return minm;
}
int main() {
  for (int i = 0; i < 4; i++)
    for (int j = 0; j < 1005; j++)
      for (int k = 0; k < 1005; k++) vis[i][j][k].first = INT_MAX;
  cin >> n >> m >> k;
  for (int i = 1; i < n + 1; i++)
    for (int j = 1; j < m + 1; j++) scanf(" %c", &a[i][j]);
  cin >> x >> y;
  cin >> x2 >> y2;
  cout << (bfs(x, y));
}
