#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <iomanip>
using ll = long long;
using uint = unsigned int;
using graph = std::vector<std::vector<ll>>;
using wGraph = std::vector<std::vector<std::pair<ll,ll>>>;
#define rep(i,n) for (int i=0; i < int(n); i++)

using namespace std;
ll MOD7 = 1000000007;
ll MOD9 = 1000000009;
vector<ll> InputVec(ll N){
    vector<ll> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    return A;
}
void OutputVec(vector<ll> A){
    for (int i = 0; i < A.size(); ++i) {
        cout << A[i] << ",";
    }
    cout << endl;
}
vector<vector<ll>> InputVec2d(ll H,ll W){
    vector<vector<ll>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<ll>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        for (int xi = 0; xi < W; ++xi) {
            cin >> A[yi][xi];
        }
    }
    return A;
}
vector<vector<char>> InputVec2dStr(ll H,ll W){
    vector<vector<char>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<char>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        string S;
        cin >> S;
        for (int xi = 0; xi < W; ++xi) {
            A[yi][xi] = S[xi];
        }
    }
    return A;
}
void OutputVec2d(vector<vector<ll>> A){
    for (int yi = 0; yi < A.size(); ++yi) {
        for (int xi = 0; xi < A[yi].size(); ++xi) {
            cout << A[yi][xi] << ",";
        }
        cout << endl;
    }
}
graph InputGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    return G;
}
graph InputDGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
    }
    return G;
}
wGraph InputWGraph(ll N,ll M){
    wGraph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b,c;
        cin >> a >> b >> c;
        a--;b--;
        G[a].push_back(make_pair(b,c));
        G[b].push_back(make_pair(a,c));
    }
    return G;
}
wGraph InputDWGraph(ll N, ll M){
    wGraph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b,c;
        cin >> a >> b >> c;
        a--;b--;
        G[a].push_back(make_pair(b,c));
    }
    return G;
}
void OutputGraph(graph G){
    for (int i = 0; i < G.size(); ++i) {
        cout << i << ":";
        for (int j = 0; j < G[i].size(); ++j) {
            cout << G[i][j]<< ",";
        }
        cout << endl;
    }
}

void OutputGraph(wGraph G){
    for (int i = 0; i < G.size(); ++i) {
        cout << i << ":";
        for (int j = 0; j < G[i].size(); ++j) {
            cout << G[i][j].first <<"/" << G[i][j].second << ",";
        }
        cout << endl;
    }
}

void OutputAnswerBool(bool b,bool isUpperCase = false){
    if(b){
        if(isUpperCase){
            cout << "YES" << endl;
        }else{
            cout << "Yes" << endl;
        }
    }else{
        if(isUpperCase){
            cout << "NO" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

int main() {
    ll H,W,K;
    cin >> H >> W >> K;
    ll sx,sy,tx,ty;
    cin >> sx >> sy >> tx >> ty;
    sx--;sy--;tx--;ty--;
    auto G = InputVec2dStr(H,W);
    vector<vector<ll>> dist(H,vector<ll>(W,1ll << 50));
    vector<vector<bool>> isL(H,vector<bool>(W,false));
    for (int yi = 0; yi < H; ++yi) {
        for (int xi = 0; xi < W; ++xi) {
            if(G[yi][xi] == '@'){
                isL[yi][xi] = true;
            }
        }
    }
    queue<pair<ll,ll>> q;
    q.push(make_pair(sx,sy));
    dist[sx][sy] = 0;
    while(!q.empty()){
        auto current = q.front();q.pop();
        for (int i = 0; i < K; ++i) {
            //R
            auto next = current;
            next.second += i + 1;
            if(next.second == W){
                break;
            }
            if(isL[next.first][next.second]){
                break;
            }
            if(dist[next.first][next.second] <= dist[current.first][current.second]){
                break;
            }
            if(dist[next.first][next.second] == (1ll << 50)){
                dist[next.first][next.second] = dist[current.first][current.second] + 1;
                q.push(make_pair(next.first,next.second));
            }
        }
        for (int i = 0; i < K; ++i) {
            //L
            auto next = current;
            next.second -= i + 1;
            if(next.second == -1){
                break;
            }
            if(isL[next.first][next.second]){
                break;
            }
            if(dist[next.first][next.second] <= dist[current.first][current.second]){
                break;
            }
            if(dist[next.first][next.second] == (1ll << 50)){
                dist[next.first][next.second] = dist[current.first][current.second] + 1;
                q.push(make_pair(next.first,next.second));
            }
        }
        for (int i = 0; i < K; ++i) {
            //U
            auto next = current;
            next.first += i + 1;
            if(next.first == H){
                break;
            }
            if(isL[next.first][next.second]){
                break;
            }
            if(dist[next.first][next.second] <= dist[current.first][current.second]){
                break;
            }
            if(dist[next.first][next.second] == (1ll << 50)){
                dist[next.first][next.second] = dist[current.first][current.second] + 1;
                q.push(make_pair(next.first,next.second));
            }
        }
        for (int i = 0; i < K; ++i) {
            //D
            auto next = current;
            next.first -= i + 1;
            if(next.first == -1){
                break;
            }
            if(isL[next.first][next.second]){
                break;
            }
            if(dist[next.first][next.second] <= dist[current.first][current.second]){
                break;
            }
            if(dist[next.first][next.second] == (1ll << 50)){
                dist[next.first][next.second] = dist[current.first][current.second] + 1;
                q.push(make_pair(next.first,next.second));
            }
        }
    }
    //OutputVec2d(dist);
    if(dist[tx][ty] == (1ll << 50)){
        cout << -1 << endl;
        return 0;
    }
    cout << dist[tx][ty] << endl;
}


Measured memory_bytes: 20016