#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

const ll INF = 1e18;

int main() {
    int h,w,k,x,y,nx,ny,K;
    cin >> h >> w >> k;
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    a--;b--;c--;d--;
    vector<string> g(h);
    rep(i,h) cin >> g[i];
    vector<int> dx = {1,-1,0,0};
    vector<int> dy = {0,0,1,-1};
    vector<vector<ll>> depth(h,vector<ll>(w,INF));
    queue<P> q;
    q.push(make_pair(b,a));
    depth[a][b] = 0;
    while (!q.empty()){
        x = q.front().first;
        y = q.front().second;
        q.pop();
        if (x==d and y==c) break;
        rep(i,4){
            nx = x;
            ny = y;
            K = k;
            while (K--){
                nx += dx[i];
                ny += dy[i];
                if (0<=nx and nx<w and 0<=ny and ny<h and g[ny][nx] != '@'
                and depth[ny][nx] > depth[y][x]){
                    if (depth[ny][nx] != depth[y][x] + 1){
                        depth[ny][nx] = depth[y][x] + 1;
                        q.push(make_pair(nx,ny));
                    } 
                }
                else break;
            }
        }
    }
    if (depth[c][d] == INF) cout << -1 << endl;
    else cout << depth[c][d] << endl;
}