#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
int h,w,k,x1,yy1,x2,y2;
int cx[]={0,0,1,-1};
int cy[]={1,-1,0,0};
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>h>>w>>k>>x1>>yy1>>x2>>y2;
    char arr[h+1][w+1];
    int dist[h+1][w+1];
    for (int i=1;i<=h;i++){
        for (int j=1;j<=w;j++){
            cin>>arr[i][j];
        }
    }
    memset(dist,-1,sizeof(dist));
    dist[x1][yy1]=0;
    queue<pair<int,int> > q;
    q.push(mp(x1,yy1));
    while (!q.empty()){
        pair<int,int> cur=q.front();
        q.pop();
        for (int i=0;i<4;i++){
            int dx=cur.first;
            int dy=cur.second;
            for (int j=0;j<k;j++){
                dx+=cx[i];
                dy+=cy[i];
                if (dx<1 || dy<1 || dx>h || dy>w) break;
                if (arr[dx][dy]=='@') break;
                if (dist[dx][dy]!=-1 && dist[dx][dy]<dist[cur.first][cur.second]+1) break;
                if (dist[dx][dy]!=-1 && dist[dx][dy]<=dist[cur.first][cur.second]+1) continue;
                dist[dx][dy]=dist[cur.first][cur.second]+1;
                q.push(mp(dx,dy));
            }
        }
    }
    cout<<dist[x2][y2];
}
