#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
vector<int> fie[1000004];
vector<int> ans[1000004];
vector<int> hidari[1000004];
vector<int> ue[1000004];
vector<int> migi[1000004];
vector<int> sita[1000004];

int main(){
    int H,W,K;
    int ys,xs,yg,xg;
    cin>>H>>W>>K>>ys>>xs>>yg>>xg;


    for(int i=0;i<=H+1;i++){
        for(int j=0;j<=W+1;j++){
            fie[i].push_back(1);
            ans[i].push_back(2100000000);
            hidari[i].push_back(0);
            migi[i].push_back(0);
            ue[i].push_back(0);
            sita[i].push_back(0);
        }
    }



    for(int i=0;i<H;i++){
        string S;
        cin>>S;
        for(int j=0;j<S.size();j++){
            if(S[j]=='.')fie[i+1][j+1]=0;

        }
    }



/*
    for(int i=0;i<=H+1;i++){
        for(int j=0;j<=W+1;j++){
            cout<<fie[i][j];
        }
        cout<<endl;
    }
*/



    queue<int>Qy,Qx,Qte;
    Qy.push(ys);
    Qx.push(xs);
    Qte.push(0);
    ans[ys][xs]=0;

    int cou=-1;

    while(!Qx.empty()){
        cou++;
        int kariy=Qy.front();Qy.pop();
        int karix=Qx.front();Qx.pop();
        int karite=Qte.front();Qte.pop();

        if(cou<10){
            //printf("[%d][%d][%d]\n",kariy,karix,karite);
        }


        for(int i=1;i<=K;i++){
                //puts("hoge");
            if(fie[kariy][karix-i]==1)break;
            if(ans[kariy][karix-i]<karite+1)break;
            if(migi[kariy][karix-i]==1)break;
            if(ans[kariy][karix-i]>karite+1){
                ans[kariy][karix-i]=karite+1;
                Qy.push(kariy);
                Qx.push(karix-i);
                Qte.push(karite+1);
                hidari[kariy][karix-i]=1;
            }
        }
        for(int i=1;i<=K;i++){
            if(fie[kariy][karix+i]==1)break;
            if(ans[kariy][karix+i]<karite+1)break;
            if(hidari[kariy][karix+i]==1)break;
            if(ans[kariy][karix+i]>karite+1){
                ans[kariy][karix+i]=karite+1;
                Qy.push(kariy);
                Qx.push(karix+i);
                Qte.push(karite+1);
                migi[kariy][karix+i]=1;
            }
        }
        for(int i=1;i<=K;i++){
            if(fie[kariy-i][karix]==1)break;
            if(ans[kariy-i][karix]<karite+1)break;
            if(ue[kariy-i][karix]==1)break;
            if(ans[kariy-i][karix]>karite+1){
                ans[kariy-i][karix]=karite+1;
                Qy.push(kariy-i);
                Qx.push(karix);
                Qte.push(karite+1);
                sita[kariy-i][karix]=1;
            }
        }
        for(int i=1;i<=K;i++){
            if(fie[kariy+i][karix]==1)break;
            if(ans[kariy+i][karix]<karite+1)break;
            if(sita[kariy+i][karix]==1)break;
            if(ans[kariy+i][karix]>karite+1){
                ans[kariy+i][karix]=karite+1;
                Qy.push(kariy+i);
                Qx.push(karix);
                Qte.push(karite+1);
                ue[kariy+i][karix]=1;
            }
        }
    }
    if(ans[yg][xg]==2100000000){
        cout<<-1<<endl;
        return 0;
    }
    cout<<ans[yg][xg]<<endl;
    return 0;
}


Measured memory_bytes: 220692