#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <iomanip>
#include <sys/time.h>
#include <random>
#include <cassert>


#define fs first
#define sc second
#define endl "\n"

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef pair<int, int> P;


int main(){
    int h, w, k;    cin >> h >> w >> k;
    int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
    x1--; y1--; x2--; y2--;

    vector<set<int>> hset(h), wset(w);
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            hset[i].insert(j);
        }
    }
    for(int i = 0; i < w; i++){
        for(int j = 0; j < h; j++){
            wset[i].insert(j);
        }
    }

    vector<vector<int>> state(h, vector<int>(w, INT32_MAX));
    vector<vector<int>> c(h, vector<int>(w, 0));
    for(int i = 0; i < h; i++){
        string s;   cin >> s;
        for(int j = 0; j < w; j++){
            if(s[j] == '@'){
                c[i][j] = 1;
            }
        }
    }

    queue<P> q;
    q.push(P(x1, y1));
    wset[y1].erase(x1);
    hset[x1].erase(y1);
    state[x1][y1] = 0;
    while(true){
        queue<P> qTmp;
        while(!q.empty()){
            P cur = q.front(); q.pop();
            int x = cur.fs, y = cur.sc;

            // hが減る方向
            while(true){
                auto itr = wset[y].lower_bound(x);
                if(itr != wset[y].begin()){
                    itr--;
                    int nex = *itr;
                    if(x - nex > k || c[nex][y] == 1){
                        break;
                    }
                    else{
                        qTmp.push(P(nex, y));
                        state[nex][y] = state[x][y] + 1;
                        wset[y].erase(nex);
                        hset[nex].erase(y);
                    }
                }
                else{
                    break;
                }
            }

            // hが増える方向
            while(true){
                auto itr = wset[y].upper_bound(x);
                if(itr != wset[y].end()){
                    int nex = *itr;
                    if(nex - x > k || c[nex][y] == 1){
                        break;
                    }
                    else{
                        qTmp.push(P(nex, y));
                        state[nex][y] = state[x][y] + 1;
                        wset[y].erase(nex);
                        hset[nex].erase(y);
                    }
                }
                else{
                    break;
                }
            }

            // wが減る方向
            while(true){
                auto itr = hset[x].lower_bound(y);
                if(itr != hset[x].begin()){
                    itr--;
                    int nex = *itr;
                    if(y - nex > k || c[x][nex] == 1){
                        break;
                    }
                    else{
                        qTmp.push(P(x, nex));
                        state[x][nex] = state[x][y] + 1;
                        hset[x].erase(nex);
                        wset[nex].erase(x);
                    }
                }
                else{
                    break;
                }
            }

            // wが増える方向
            while(true){
                auto itr = hset[x].upper_bound(y);
                if(itr != hset[x].end()){
                    int nex = *itr;
                    if(nex - y > k || c[x][nex] == 1){
                        break;
                    }
                    else{
                        qTmp.push(P(x, nex));
                        state[x][nex] = state[x][y] + 1;
                        hset[x].erase(nex);
                        wset[nex].erase(x);
                    }
                }
                else{
                    break;
                }
            }

        }
        if(qTmp.empty()) break;
        q = qTmp;
    }

    if(state[x2][y2] == INT32_MAX){
        cout << -1 << endl;
    }
    else{
        cout << state[x2][y2] << endl;
    }


    return 0;
}


Measured memory_bytes: 155608