/** BISMILLAH, AR-RAHMAN, AR-RAHIM **
*** Giving up is the only sure way to fail ***

    Md. Mujahedul Azad (Turin)
    FB : FB/Md.turin01
    GH : GITHUB/turin1602101
    Hajee Mohammad Danesh Science & Technology University( H S T U ) */

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

#define IL inline
#define ST template<int M>
#define TP template<class T>
#define UP template<class T, class U>
#define HP template<class H, class...T>

#define sq(x)           ((x)*(x))
#define cb(x)           ((x)*sq(x))
#define abs(x)          ((x)<0?-(x):(x))
#define max(a,b)        ((a)<(b)?(b):(a))
#define min(a,b)        ((a)<(b)?(a):(b))

#define gp              ' '
#define nl              '\n'
#define sc              scanf
#define ff              first
#define se              second
#define pf              printf
#define pc              putchar
#define G(a)            get<(a)>
#define gc              getchar()
#define pb              push_back
#define mp              make_pair
#define mt              make_tuple
#define lb              lower_bound
#define ub              upper_bound
#define eb              emplace_back
#define amax(a,b)       a = max(a,b)
#define amin(a,b)       a = min(a,b)
#define rint            register int
#define FLUSH           fflush(stdout)
#define all(x)          x.begin(),x.end()
#define rall(x)         x.rbegin(),x.rend()
#define Clr(x)          memset(x,0,sizeof(x))
#define Set(x)          memset(x,-1,sizeof(x))
#define fr(i,a,b)       for(rint i=a; i<b; i++)
#define rf(i,a,b)       for(rint i=b; i>=a; i--)
#define precision(x)    cout<<fixed<<setprecision(x)
#define fileIO(name)    freopen(name".in", "r", stdin);\
                        freopen(name".out", "w", stdout)

TP IL bool read(T&);IL bool read(char&);IL bool read(char*);HP IL bool read(H&,T&...);
TP IL void write(T);IL void write(char);IL void write(char*);IL void write(const char*);HP IL void write(H,T...);
TP IL T gcd(T,T);TP IL T lcm(T,T);TP IL T power(T,T);TP IL T MulL(T,T,T);TP IL T power(T,T,T);TP IL T powerL(T,T,T);
TP IL void in(T*,size_t);TP IL void in(vector<T>&,size_t);TP IL void out(T*,size_t);TP IL void out(vector<T>&,size_t);
const int dx[] = {1,-1,0,0,-1,1,-1,1}, dy[] = {0,0,-1,1,1,1,-1,-1}, kx[] = {-2,-1,1,2,2,1,-1,-2}, ky[] = {1,2,2,1,-1,-2,-2,-1};
const int MODF = 998244353, MOD7 = 1000000007, MOD9 = 1000000009, INF = 0x3f3f3f3f; const long double EPS = 1e-9, PI = acos(-1.0);
using tpl=tuple<int,int,int>;using ll=long long;using ld=long double;using vl=vector<ll>;using vi=vector<int>;using ii=pair<int,int>;using iii=pair<int, ii>;
IL int rand(int,int);IL ll randLL(ll,ll);IL void inRand(int*,int,int,int);void inRandLL(ll*,int,ll,ll);IL void inRand(vi&,int,int,int);IL void inRandLL(vl&,int,ll,ll);
ST struct Calculator{IL ll Inv(ll);IL ll Add(ll,ll);IL ll Sub(ll,ll);IL ll Mul(ll,ll);IL ll Div(ll,ll);};

Calculator<MOD7> C;
const int mx = 1e6+10;

int n, m, k;
int sx,sy,ex,ey;

vector<vi> dis;
vector<string> s;

IL void MAIN(int &cs){
//    write("Case ", cs, ": ");
    read(n,m,k,sx,sy,ex,ey);
    sx--; sy--; ex--; ey--;

    s.resize(n);
    dis.assign(n,vi(m,INF));

    fr(i,0,n) cin>>s[i];
    queue<ii> q; q.push(ii(sx,sy)); dis[sx][sy]=0;
    while(q.size()){ii p=q.front(); q.pop(); int x=p.ff, y=p.se;
        fr(i,0,4) fr(j,1,k+1){
            int xx=x+j*dx[i], yy=y+j*dy[i];
            if(xx<0 || xx>=n || yy<0 || yy>=m) break;
            if(s[xx][yy] == '@' || dis[xx][yy]<=dis[x][y]) break;
            if(dis[xx][yy] > dis[x][y]+1){
                dis[xx][yy] = dis[x][y]+1;
                q.push(ii(xx,yy));
            }
        }
    }

    if(dis[ex][ey] == INF) puts("-1");
    else write(dis[ex][ey], nl);
}

int main(){
    int tc = 1; ///read( tc );
    fr(cs, 1, tc+1) MAIN(cs);
    return 0;
}

char os[25];TP IL void in(T *a,size_t n){fr(i,0,n)read(a[i]);}TP IL void in(vector<T> &a,size_t n){fr(i,0,n)read(a[i]);}TP IL void out(T *a,size_t n){fr(i,0,n)write(a[i],(i+1==n)?nl:gp);}TP IL void out(vector<T> &a,size_t n){fr(i,0,n)write(a[i],(i+1==n)?nl:gp);}
ST IL ll Calculator<M>::Add(ll x,ll y){return (x+y)%M;}ST IL ll Calculator<M>::Inv(ll x){return power<ll>(x,M-2,M);}ST IL ll Calculator<M>::Sub(ll x,ll y){return (((x-y)%M)+M)%M;}ST IL ll Calculator<M>::Mul(ll x,ll y){return ((x%M)*(y%M));}ST IL ll Calculator<M>::Div(ll x,ll y){return Mul(x,Inv(y));}
TP IL void write(T x){if(x==0){pc('0'); return;}int i=0; bool neg=(x<0);if(neg)pc('-'),x=-x;while(x>0) {os[i++]=(x%10)+'0';x/=10;}i--; while(i>=0) pc(os[i--]);}IL void write(char *s){pf("%s",s);}IL void write(const char *s){pf("%s",s);}IL void write(char c){pc(c);}HP IL void write(H h, T ...t){write(h); write(t...);}
TP IL bool read(T &val){val=0;bool neg=0;char ch=gc;while(ch <'0' || ch >'9'){if(ch=='-') neg=1;else if(ch==EOF)return 0;ch=gc;}while(ch>='0' && ch<='9'){val=(val*10)+(ch-'0');ch=gc;}if(neg)val=-val;return 1;}HP IL bool read(H& h, T&... t){return read(h)&&read(t...);}IL bool read(char &c){c=gc;return c!=EOF;}IL bool read(char *s){return scanf("%s",s);}
TP IL T lcm(T a,T b){return (a/gcd(a,b))*b;}TP IL T gcd(T a,T b){return b?gcd(b,a%b):a;}TP IL T power(T v,T p){T r=1;while(p>0){if(p & 0x1)r=(r*v);v=(v*v);p>>=1;}return r;}TP IL T power(T v,T p,T m){v%=m;T r=1;while(p>0){if(p & 0x1)r=(r*1LL*v)%m;v=(v*1LL*v)%m;p>>=1;}return r;}TP IL T powerL(T v,T p,T m){v%=m;T r=1;while(p>0){if(p & 0x1)r=MulL(r,v,m);v=MulL(v,v,m);p>>=1;}return r;}TP IL T MulL(T a, T b, T m){T r=0;a%=m;b%=m;while(b){if(b & 0x1)r=(r+a)%m;b>>=1;if(a<m-a)a<<=1;else a-=(m-a);}return r;}


Measured memory_bytes: 10980