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

int main(){
    int H, W, K;
    cin >> H >> W >> K;
    int sx, sy, gx, gy;
    cin >> sx >> sy >> gx >> gy;
    sx--; sy--; gx--; gy--;
    vector<vector<bool>> avail(H);
    for(int i=0; i<H; i++){
        string s;
        cin >> s;
        avail[i].resize(W);
        for(int j=0; j<W; j++) avail[i][j] = (s[j] == '.');
    }

    int dx[] = {-1, 1, 0, 0};
    int dy[] = {0, 0, -1, 1};
    auto inside = [&](int i, int j){ return i>=0 && i<H && j>=0 && j<W && avail[i][j]; };

    vector<vector<int>> dist(H, vector<int>(W, 1e9));
    queue<pair<int, int>> que;
    que.emplace(sx, sy);
    dist[sx][sy] = 0;

    while(que.size()){
        auto [i, j] = que.front(); que.pop();
        for(int k=0; k<4; k++) for(int d=1; d<=K; d++){
            int x = i+d*dx[k], y = j+d*dy[k];
            if(!inside(x, y) || dist[x][y] <= dist[i][j]) break;
            if(dist[x][y] == 1e9){
                dist[x][y] = dist[i][j] + 1;
                que.emplace(x, y);
            }
        }
    }

    int ans = dist[gx][gy];
    if(ans == 1e9) ans = -1;
    cout << ans << endl;
    return 0;
}
