#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = (ll)a;i < (ll)b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = (ll)b-1LL;i >= (ll)a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define SIGN(a) (a==0?0:(a>0?1:-1))

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;
typedef long double ld;
typedef pair<ld,ld> pdd;

const ll INF=(1LL<<60);
#if __cplusplus<201700L
ll gcd(ll a, ll b) {
  a=abs(a);
  b=abs(b);
  if(a==0)return b;
  if(b==0)return a;
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif
template<class T>
bool chmax(T& a,const T& b){
  if(a<b){
    a=b;
    return true;
  }
  return false;
}
template<class T>
bool chmin(T& a,const T& b){
  if(a>b){
    a=b;
    return true;
  }
  return false;
}
template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}


pll operator+(pll a,pll b){
  return pll(a.first+b.first,a.second+b.second);
}
pll operator*(ll a,pll b){
  return pll(b.first*a,b.second*a);
}
int main(){
  cout<<setprecision(1000);
  pll start,goal;
  ll H,W,K;
  scanf("%lld%lld%lld",&H,&W,&K);
  scanf("%lld%lld%lld%lld",&start.first,&start.second,&goal.first,&goal.second);
  start=start+pll(-1,-1);
  goal=goal+pll(-1,-1);
  vector<string> _v(H);
  REP(H){
    cin>>_v[i];
  }
  vector<vector<ll>> v(H,vector<ll>(W));
  For(i,H){
    For(j,W){
      if(_v[i][j]=='@'){
        v[i][j]=-1;
      }else{
        v[i][j]=-2;
      }
    }
  }
  auto isinike=[H,W,&v](pll a){
    if(0<=a.first&&0<=a.second&&a.first<H&&a.second<W&&v[a.first][a.second]!=-1){
      return true;
    }
    return false;
  };
  v[start.first][start.second]=0;
  deque<tuple<pll,ll>> q;
  for (auto &&i : {pll(1,0),pll(0,1),pll(-1,0),pll(0,-1)})
  {
    FOR(j,1,max(H,W)){
      if(isinike(start+j*i)){
        pll x=start+j*i;
        v[x.first][x.second]=(j/K)+(j%K?1:0);
        if(i.first==0)q.push_back(make_tuple(x,0));
        else q.push_front(make_tuple(x,1));
      }else{
        break;
      }
    }
  }
  while(!q.empty()){
    pll cur;
    ll cmd;
    tie(cur,cmd)=q.back();q.pop_back();
    ll distcur=v[cur.first][cur.second];
    vector<pll> x;
    if(cmd==0)x={pll(1,0),pll(-1,0)};
    else x={pll(0,1),pll(0,-1)};
    for (auto &&dir : x)
    {
      FOR(dist,1,max(H,W)){
        pll next=cur+dist*dir;
        ll nextdist=distcur+(dist/K+(dist%K?1:0));
        if(isinike(next)){
          ll x=next.first,y=next.second;
          if(v[x][y]==-2||v[x][y]>nextdist){
            v[x][y]=nextdist;
            q.push_front(make_tuple(next,(cmd==0?1LL:0LL)));
          }else if(v[x][y]<=distcur){
            break;
          }
        }else{
          break;
        }
      }
    }
    
  }
  if(v[goal.first][goal.second]<0)cout<<-1<<endl;
  else  cout<<v[goal.first][goal.second]<<endl;
  return 0;
}


Measured memory_bytes: 26660