// Problem : D. Olya and Energy Drinks
// Contest : Codeforces - Codeforces Round #442 (Div. 2)
// URL : https://codeforces.com/contest/877/problem/D
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#define int long long
#define fastio                      \
  ios_base::sync_with_stdio(false); \
  cin.tie(0);                       \
  cout.tie(0);
#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define db1(x) cout << #x << "=" << x << endl
#define db2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z)                                                       \
  cout << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z \
       << endl
#define dbp(x) \
  cout << #x << "= {" << (x.first) << ", " << (x.second) << "}" << endl;
#define dbv(v)                         \
  {                                    \
    cout << #v << " : ";               \
    for (auto x : v) cout << x << ' '; \
    cout << endl;                      \
  }
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define rep2(i, a, b) for (int i = a; i >= b; i--)
#define die(x) return cout << x << '\n', 0;

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

int32_t main() {
  fastio;

  int testcases;
  testcases = 1;
  //  cin >> testcases;

  while (testcases--) {
    int n, m, k;
    cin >> n >> m >> k;
    vector<vector<char> > board(n, vector<char>(m));
    vector<vector<int> > moves(n, vector<int>(m, INT_MAX));
    int x1, x2, y1, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    rep(i, 0, n - 1) rep(j, 0, m - 1) cin >> board[i][j];

    x1--;
    x2--;
    y1--;
    y2--;

    queue<pii> q;
    q.push({x1, y1});
    vector<set<int> > cols(m), rows(n);
    moves[x1][y1] = 0;
    rep(i, 0, n - 1) rep(j, 0, m - 1) rows[i].insert(j);
    rep(j, 0, m - 1) rep(i, 0, n - 1) cols[j].insert(i);
    rows[x1].erase(y1);
    cols[y1].erase(x1);
    while (!q.empty()) {
      pii t = q.front();
      int tx = t.first;
      int ty = t.second;
      q.pop();
      int c = moves[tx][ty];
      //      db3(tx, ty, c);
      rep2(i, tx - 1, max(0LL, tx - k)) {
        if (!rows[i].count(ty) || board[i][ty] == '@' || moves[i][ty] < c + 1)
          break;
        rows[i].erase(ty);
        //        cols[ty].erase(i);
        moves[i][ty] = min(moves[i][ty], c + 1);
        q.push({i, ty});
      }
      rep2(j, ty - 1, max(0LL, ty - k)) {
        if (!cols[j].count(tx) || board[tx][j] == '@' || moves[tx][j] < c + 1)
          break;
        cols[j].erase(tx);
        //  rows[tx].erase(j);
        moves[tx][j] = min(moves[tx][j], c + 1);
        q.push({tx, j});
      }
      rep(i, tx + 1, min(n - 1, tx + k)) {
        if (!rows[i].count(ty) || board[i][ty] == '@' || moves[i][ty] < c + 1)
          break;
        rows[i].erase(ty);
        // cols[ty].erase(i);
        moves[i][ty] = min(moves[i][ty], c + 1);
        q.push({i, ty});
      }
      rep(j, ty + 1, min(m - 1, ty + k)) {
        if (!cols[j].count(tx) || board[tx][j] == '@' || moves[tx][j] < c + 1)
          break;
        cols[j].erase(tx);
        // rows[tx].erase(j);
        moves[tx][j] = min(moves[tx][j], c + 1);
        q.push({tx, j});
      }
    }
    if (moves[x2][y2] == INT_MAX) die(-1);
    cout << moves[x2][y2];
  }

  return 0;
}


Measured memory_bytes: 152600