#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
// template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef pair <int,P> PP;
typedef long double ld;

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w, k;
    int INF = 1e8;
    cin >> h >> w >> k;
    int x1,y1,x2,y2; cin >> x1 >> y1 >> x2 >> y2;
    vector<string> s(h); rep (i, h) cin >> s[i];
    vector<vector<P>> d(h, vector<P>(w, P{INF, -1}));

    x1--;y1--;x2--;y2--;
    d[x1][y1].first = 0;
    queue<PP> que; que.emplace(0, P{x1, y1});
    while (!que.empty()) {
        auto [dist, p] = que.front(); que.pop();
        auto [x, y] = p;
        eprintf("(%d,%d)\n", x,y);
        if (dist > d[x][y].first) continue;
        // int count;
        // count = 0;
        for (int i = 1; i <= k; i++) {
            int xx = x + i; if (xx >= h) break;
            if (d[xx][y].first <= dist || s[xx][y] == '@') break;
            // if (d[xx][y].first == dist + 1) count++;
            // if (count == 2) break;
            if (d[xx][y].second == 0) break;
            d[xx][y] = P{dist + 1, 0}; que.emplace(d[xx][y].first, P{xx, y});
        }
        for (int i = 1; i <= k; i++) {
            int xx = x - i; if (xx < 0) break;
            if (d[xx][y].first <= dist || s[xx][y] == '@') break;
            // if (d[xx][y].first == dist + 1) count++;
            // if (count == 2) break;
            if (d[xx][y].second == 0) break;
            d[xx][y] = P{dist + 1, 0}; que.emplace(d[xx][y].first, P{xx, y});
        }
        for (int i = 1; i <= k; i++) {
            int yy = y - i; if (yy < 0) break;
            if (d[x][yy].first <= dist || s[x][yy] == '@') break;
            // if (d[x][yy].first == dist + 1) count++;
            if (d[x][yy].second == 1) break;
            d[x][yy] = P{dist + 1, 1}; que.emplace(d[x][yy].first, P{x, yy});
        }
        for (int i = 1; i <= k; i++) {
            int yy = y + i; if (yy >= w) break;
            if (d[x][yy].first <= dist || s[x][yy] == '@') break;
            // if (d[x][yy].first == dist + 1) count++;
            if (d[x][yy].second == 1) break;
            d[x][yy] = P{dist + 1, 1}; que.emplace(d[x][yy].first, P{x, yy});
        }
    }

    // rep (i, h) {
    //     rep (j, w) {
    //         if (d[i][j] >= INF) eprintf("- ");
    //         else eprintf("%d ", d[i][j]);
    //     }
    //     eprintf("\n");
    // }
    if (d[x2][y2].first >= INF) cout << -1 << "\n";
    else cout << d[x2][y2].first << "\n";
    return 0;
}


Measured memory_bytes: 19840