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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
 
#define FS              ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll              long long int
#define ld              long double
#define pb              push_back
#define bp              __builtin_popcount
#define sz              size()
#define ff              first
#define ss              second
#define vll             vector<ll>
#define vbool           vector<bool>
#define vpll            vector<pair<ll,ll>>
#define pll             pair<ll,ll>
#define vllv            vector<vector<ll>>
#define setpri(x)       cout<<setprecision(x)<<fixed;
#define all(v)          v.begin(),v.end()
#define allr(v)         v.rbegin(),v.rend()
#define yesr {cout<<"YES"<<endl;return;}
#define nor {cout<<"NO"<<endl;return;}
// getline (std::cin,name);
ll MOD=1e9+7;
ll ceil1(ll n,ll x){return (n-1)/x+(n>0);}

ll gcd(ll a,ll b){return __gcd(a,b);}
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}

ll pow1(ll n,ll m ,ll mod=MOD );
ll pow2(ll n,ll k);

ll modinv(ll n,ll mod){  return pow1(n,mod-2,mod);}

bool func(pair<ll,ll> &a,pair<ll,ll> &b ){
        if(a.ff != b.ff)return a.ff < b.ff;
        return a.ss > b.ss;
}
ll const N=(ll)2e5+111;
ll const LG=(ll)log2(N)+1;
ll dx[]={0,0,1,-1};
ll dy[]={1,-1,0,0};
bool isval(vector<string>&s,ll x,ll y,ll n,ll m){
        if(x<=0 || y<=0 || x>n || y>m)return false;
        if(s[x][y]=='@')return false;
        return true;
}
void solve(){
        ll i,j,k,l,n,m,x,y,z,r;
        ll x1,x2,y1,y2;
        cin>>n>>m>>k;
        cin>>x1>>y1>>x2>>y2;
        
        vector<string> s(n+1);
        for(i=1;i<=n;i++){
                cin>>s[i];
                s[i]=' '+s[i];
        }
        
        vllv dis(n+1,vll(m+1,1e11));
        vllv vis(n+1,vll(m+1));
        
        queue<pll> q;
        q.push({x1,y1});
        vis[x1][y1]=true;
        dis[x1][y1]=0;
        while(!q.empty()){
                x=q.front().ff;
                y=q.front().ss;
                q.pop();
                for(i=0;i<4;i++){
                        
                        for(j=1;j<=k;j++){
                                ll nx=x+dx[i]*j;
                                ll ny=y+dy[i]*j;
                                
                                if(!isval(s,nx,ny,n,m))break;
                                
                                if(dis[nx][ny]<dis[x][y]+1)break;
                                if(vis[nx][ny])continue;
                                dis[nx][ny]=dis[x][y]+1;
                                vis[nx][ny]=true;
                                q.push({nx,ny});
                        }
                }
        }
        if(dis[x2][y2]==1e11)dis[x2][y2]=-1;
        
        cout<<dis[x2][y2]<<endl;
        
       
}   
int main(){
        FS;
        
        ll i,j,k,n,m,x,y,z,q;
        q=1;
        // cin>>q;
        while(q--){
                solve();
        }
        return 0;
}


ll pow1(ll n,ll m,ll mod){
        if(m==0)return 1;
        
        if(m%2==0)return pow1((n*n)%mod,m/2,mod);
    	
    	return (pow1((n*n)%mod,m/2,mod)*n)%mod;
}

ll pow2(ll n,ll k){
        ll ans=1;
            while(k>0){
                if(k%2==1)ans=ans*n;
                n=n*n;
                k/=2;
            }
            return ans;
}


Measured memory_bytes: 43292