#include <bits/stdc++.h>
using namespace std;
const int Max = 1e3 + 10;
const int Mod = 1e9 + 7;
const long long int Inf = 1LL << 62;
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};
int dist[Max][Max];
int n, m, k;
char str[Max][Max];
bool solve(int r, int c) {
  if (r >= 1 && r <= n && c >= 1 && c <= m && str[r][c] == '.')
    return true;
  else
    return false;
}
int BFS(int x1, int y1, int x2, int y2) {
  memset(dist, -1, sizeof dist);
  queue<pair<int, int> > q;
  q.push({x1, y1});
  dist[x1][y1] = 0;
  while (!q.empty() && dist[x2][y2] == -1) {
    int u = q.front().first;
    int v = q.front().second;
    q.pop();
    for (int i = 0; i < 4; i++) {
      for (int cur = 1; cur <= k; cur++) {
        int x = u;
        int y = v;
        if (dx[i] != 0) x += (dx[i] * cur);
        if (dy[i] != 0) y += (dy[i] * cur);
        if (solve(x, y) == 0) break;
        if (dist[x][y] == -1) {
          dist[x][y] = dist[u][v] + 1;
          q.push({x, y});
        }
      }
    }
  }
  return dist[x2][y2];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> str[i][j];
    }
  }
  int x1, x2, y1, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int res = BFS(x1, y1, x2, y2);
  cout << res << endl;
  return 0;
}
