#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#pragma warning(disable:4996) 

typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define LINF3 1000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;

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

typedef pair<pair<int,int>,int> Q;

char str[1000005];
int a[1000005];
void solve()
{
    int h, w, K;
    scanf("%d%d%d", &h, &w, &K);
    int x0, y0, x1, y1;
    scanf("%d%d%d%d", &x0, &y0, &x1, &y1); x0--; y0--; x1--; y1--;
#define P(i,j) ((i)*w+(j))
    int ss = P(x0, y0), ee = P(x1, y1);

    int i, j;
    for (i = 0; i < h; i++) {
        scanf("%s", str);
        for (j = 0; j < w; j++) {
            if (str[j] == '@') {
                a[P(i, j)] = 1;
            }
        }
    }    

    priority_queue< Q, vector<Q>, greater<Q> > que;
    vector<pair<int, int> > d(h*w * 4, make_pair(INF, INF));
    d[ss*4] = make_pair(0,0);
    d[ss*4+1] = make_pair(0,0);
    d[ss*4+2] = make_pair(0,0);
    d[ss*4+3] = make_pair(0,0);
    int kk;
    for (kk = 0; kk < 4; kk++) {
        que.push(Q(make_pair(0,0), ss * 4 + kk));
    }
    while(!que.empty()){
        int curr  = que.top().second;
        int curri = curr % 4;
        int currxy = curr / 4;
        int currx = currxy / w;
        int curry = currxy % w;
        pair<int, int> dcurr = que.top().first;
        int dcurr0 = que.top().first.first;
        int dcurr1 = que.top().first.second;
        que.pop();
        if(d[curr] < dcurr) continue;
        int i;
        for(i=0; i<4; i++){
            int nextx = currx + dx[i];
            int nexty = curry + dy[i];
            if (nextx < 0 || nextx >= h || nexty < 0 || nexty >= w) continue;
            if (a[P(nextx, nexty)]) continue;

            int next = P(nextx, nexty) * 4 + i;
            pair<int, int> distnew;
            if (curri == i) {
                int aa = (dcurr1 + 1) / K;
                distnew = make_pair(dcurr0+aa, dcurr1 + 1-aa*K);
            }
            else {
                int aa=dcurr1 / K;
                if (dcurr1%K) aa++;
                distnew = make_pair(dcurr0 + aa, 1);
            }
            if(d[next] > distnew){
                d[next] = distnew;
                que.push(Q(distnew, next));
            }
        }
    }

    int ans = INF;
    for (i = 0; i < 4; i++) {
        int dcurr0=d[ee * 4 + i].first;
        int dcurr1=d[ee * 4 + i].second;
        if (dcurr0 == INF) continue;
        if (dcurr1) {
            int aa=dcurr1 / K;
            if (dcurr1%K) aa++;
            dcurr0 += aa;
        }
        ans = MIN(ans, dcurr0);
    }
    if (ans == INF) {
        printf("-1\n");
    }
    else {
        printf("%d\n", ans);
    }
    return;
}


int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}


Measured memory_bytes: 38928