#include <bits/stdc++.h>
using namespace std;

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair

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<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define INF 1152921504606846976

const i64 dy[4] = {0, 1, 0, -1};
const i64 dx[4] = {1, 0, -1, 0};

int main() {
    i64 H, W, K; cin >> H >> W >> K;
    i64 sy, sx, gy, gx; cin >> sy >> sx >> gy >> gx;
    sx--, sy--, gx--, gy--;
    i64 spos = sy * W + sx;
    i64 gpos = gy * W + gx;

    vector<char> G(H * W);
    REP(y, H) REP(x, W) cin >> G[y * W + x];

    using pll = pair<i64, i64>;
    using P = pair<pll, pll>;
    vector<vector<pll>> dp(H * W, vector<pll>(4, {INF, K}));

    priority_queue<P, vector<P>, greater<P>> pq;
    REP(i, 4) {
        dp[spos][i] = {0, 0};
        pq.push({dp[spos][i], {spos, i}});
    }

    auto idx2pos = [&](i64 idx) -> pair<i64, i64> {
        i64 y = idx / W;
        i64 x = idx % W;
        return {y, x};
    };

    while (!pq.empty()) {
        auto [obj, state] = pq.top(); pq.pop();

        if (dp[state.first][state.second] < obj) continue;

        REP(i, 4) {
            if (i == state.second) {
                pll ns = state;
                auto [ny, nx] = idx2pos(ns.first);
                ny += dy[i];
                nx += dx[i];
                if (ny < 0 || H <= ny || nx < 0 || W <= nx) continue;
                ns.first = ny * W + nx;
                if (G[ns.first] == '@') continue;
                pll no = obj;
                no.second++;
                if (no.second == K) {
                    no.first++;
                    no.second = 0;
                }
                if (chmin(dp[ns.first][ns.second], no)) {
                    pq.push({no, ns});
                }
            } else {
                pll ns = state;
                ns.second = i;
                pll no = obj;
                if (no.second > 0) no.first++;
                no.second = 0;
                if (chmin(dp[ns.first][ns.second], no)) {
                    pq.push({no, ns});
                }
            }
        }
    }

    i64 minv = INF;
    REP(i, 4) {
        if (dp[gpos][i].second == 0) {
            chmin(minv, dp[gpos][i].first);
        }
    }
    cout << (minv == INF ? -1 : minv) << endl;

    return 0;
}

Measured memory_bytes: 122040