#include<bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,a,n) for(int i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define FI first
#define SE second
#define maxn 1000000
#define mod 1000000007
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef double db;

char str[maxn+5];
vector<vi> s,dis,ok,LEFT,RIGHT,UP,DOWN;
vector<vi> prel,prer,preu,pred;

int getLEFT(int x,int y)
{
    if(ok[x][LEFT[x][y]]) return LEFT[x][y];
    return LEFT[x][y]=getLEFT(x,LEFT[x][y]);
}
int getRIGHT(int x,int y)
{
    if(ok[x][RIGHT[x][y]]) return RIGHT[x][y];
    return RIGHT[x][y]=getRIGHT(x,RIGHT[x][y]);
}
int getUP(int x,int y)
{
    if(ok[UP[x][y]][y]) return UP[x][y];
    return UP[x][y]=getUP(UP[x][y],y);
}
int getDOWN(int x,int y)
{
    if(ok[DOWN[x][y]][y]) return DOWN[x][y];
    return DOWN[x][y]=getDOWN(DOWN[x][y],y);
}

int main()
{
    int H,W,K; scanf("%d%d%d",&H,&W,&K);
    vi dummy(W+2,0);
    s.resize(H+2,dummy);
    dis.resize(H+2,dummy);
    ok.resize(H+2,dummy);
    LEFT.resize(H+2,dummy);
    RIGHT.resize(H+2,dummy);
    UP.resize(H+2,dummy);
    DOWN.resize(H+2,dummy);
    prel.resize(H+2,dummy);
    pred.resize(H+2,dummy);
    preu.resize(H+2,dummy);
    prer.resize(H+2,dummy);

    int x1,y1,x2,y2; scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
    rep(i,1,H) 
    {
        scanf("%s",str+1);
        rep(j,1,W) s[i][j]=(str[j]=='.');
    }
    rep(i,1,H) rep(j,1,W) dis[i][j]=-1;
    rep(i,0,H+1) rep(j,0,W+1) ok[i][j]=1;
    rep(i,1,H) rep(j,1,W) LEFT[i][j]=j-1;
    rep(i,1,H) rep(j,1,W) RIGHT[i][j]=j+1;
    rep(i,1,H) rep(j,1,W) UP[i][j]=i-1;
    rep(i,1,H) rep(j,1,W) DOWN[i][j]=i+1;
    rep(i,1,H)
    {
        prel[i][0]=0;
        rep(j,1,W) prel[i][j]=s[i][j]==0?j:prel[i][j-1];
    }
    rep(i,1,H)
    {
        prer[i][W+1]=W+1;
        per(j,1,W) prer[i][j]=s[i][j]==0?j:prer[i][j+1];
    }
    rep(j,1,W)
    {
        preu[0][j]=0;
        rep(i,1,H) preu[i][j]=s[i][j]==0?i:preu[i-1][j];
    }
    rep(j,1,W)
    {
        pred[H+1][j]=H+1;
        per(i,1,H) pred[i][j]=s[i][j]==0?i:pred[i+1][j];
    }
    dis[x1][y1]=0;
    queue<pii> q;
    q.push(mp(x1,y1));
    ok[x1][y1]=0;

    while(q.size())
    {
        int x=q.front().FI;
        int y=q.front().SE;
        q.pop();
        while(1)
        {
            int ny=getLEFT(x,y);
            if(ny==0 || ny<y-K || ny<=prel[x][y]) break;
            ok[x][ny]=0;
            dis[x][ny]=dis[x][y]+1;
            q.push(mp(x,ny));
        }
        while(1)
        {
            int ny=getRIGHT(x,y);
            if(ny==W+1 || ny>y+K || ny>=prer[x][y]) break;
            ok[x][ny]=0;
            dis[x][ny]=dis[x][y]+1;
            q.push(mp(x,ny));
        }
        while(1)
        {
            int nx=getUP(x,y);
            if(nx==0 || nx<x-K || nx<=preu[x][y]) break;
            ok[nx][y]=0;
            dis[nx][y]=dis[x][y]+1;
            q.push(mp(nx,y));
        }
        while(1)
        {
            int nx=getDOWN(x,y);
            if(nx==H+1 || nx>x+K || nx>=pred[x][y]) break;
            ok[nx][y]=0;
            dis[nx][y]=dis[x][y]+1;
            q.push(mp(nx,y));
        }
    }
    printf("%d\n",dis[x2][y2]);
    return 0;
}

Measured memory_bytes: 137144