#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl '\n'
//#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define BIT(n) (1LL << (n))
#define TOUPPER(s) transform(s.begin(), s.end(), s.begin(), ::toupper)
#define TOLOWER(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
#define FILLZERO(s, n)                      \
    do {                                    \
        ostringstream os;                   \
        os << setw(n) << setfill('0') << s; \
        s = os.str();                       \
    } while (0);
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
#define INIT                               \
    std::cin.tie(nullptr);                 \
    std::ios_base::sync_with_stdio(false); \
    cout << std::fixed << std::setprecision(10);

using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using pi = pair<int, int>;
template <typename T>
using Pq = priority_queue<T>;
template <typename T>
using pQ = priority_queue<T, vector<T>, greater<T>>;

template <typename T>
vector<T> make_vec(size_t a, T n) { return vector<T>(a, n); }
template <typename T, typename... Ts>
auto make_vec(size_t a, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...)); }
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
struct Grid {
protected:
    int height, width;

public:
    vector<vector<T>> data;
    int dh[8] = {1, 0, -1, 0, 1, 1, -1, -1};
    int dw[8] = {0, 1, 0, -1, 1, -1, 1, -1};
    int inf = numeric_limits<int>::max();

    Grid(int h, int w) : height(h), width(w), data(h, vector<T>(w)) {}
    Grid(int h, int w, T e) : height(h), width(w), data(h, vector<T>(w, e)) {}
    T &operator()(int h, int w) {
        if (isOutside(h, w)) {
            fprintf(stderr, "(h : %d, w : %d) : index out of bounds!\n", h, w);
            exit(1);
        }
        return data[h][w];
    }

    bool isOutside(int h, int w) {
        return (h < 0 || height <= h || w < 0 || width <= w);
    }

    int dijkstra(pair<int, int> start, pair<int, int> end) {
        using P = pair<pair<int, pair<int, int>>, pair<int, int>>;
        vector<Grid<int>> res(4, Grid<int>(height, width, inf));
        auto used = make_vec<int>(4, height, width, 0);
        //queue<P> q; //隣接マス間の距離が１のみの場合（それ以外はpqを使う）
        priority_queue<P, vector<P>, greater<P>> q;
        REP(i, 4)
        res[i](start.first, start.second) = 0;
        q.push(make_pair(make_pair(0, make_pair(K, 0)), start));
        while (!q.empty()) {
            auto tmp = q.top();
            q.pop();
            auto now = tmp.second;
            auto [k, dir] = tmp.first.second;
            if (used[dir][now.first][now.second])
                continue;
            used[dir][now.first][now.second] = 1;
            for (int i = 0; i < 4; i++) {
                pair<int, int> nxt = {now.first + dh[i], now.second + dw[i]};
                if (isOutside(nxt.first, nxt.second))
                    continue;
                if ((*this)(nxt.first, nxt.second) == '@')
                    continue;
                int dist = (i == dir && k < K) ? 0 : 1; //グリッドグラフなのでとりあえず（問題によって適宜変える）
                int nxtK = (i == dir) ? k % K + 1 : 1;
                if (res[i](nxt.first, nxt.second) > res[dir](now.first, now.second) + dist) {
                    res[i](nxt.first, nxt.second) = res[dir](now.first, now.second) + dist;
                    q.push(make_pair(make_pair(res[i](nxt.first, nxt.second), make_pair(nxtK, i)), nxt));
                }
            }
        }
        res[0].debug(" ", 10);
        int tmp = INF;
        REP(i, 4)
        chmin(tmp, res[i](end.first, end.second));
        return tmp;
    }

    void debug(string sep = "", int n = 1) {
#ifdef LOCAL
        //cout << setw(w);
        for (int h = 0; h < height; h++) {
            for (int w = 0; w < width; w++) {
                cout << setw(n) << data[h][w] << sep;
            }
            cout << endl;
        }
#endif
    }

    void print(string sep = "") {
        for (int h = 0; h < height; h++) {
            for (int w = 0; w < width; w++) {
                cout << data[h][w] << sep;
            }
            cout << endl;
        }
    }
};

int main() {
    INIT;
    cin >> H >> W >> K;
    cin >> A >> B >> C >> D;
    Grid g(H, W, '.');
    REP(h, H) {
        cin >> S;
        REP(w, W) {
            g(h, w) = S[w];
        }
    }
    auto d = g.dijkstra({A - 1, B - 1}, {C - 1, D - 1});
    cout << ((d == INF) ? -1 : d) << endl;
}

Measured memory_bytes: 44668