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

//template
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
template<typename T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
//end

typedef pair<int,int> P;
typedef pair<int,P> T;

int dx[]={1,-1,0,0},dy[]={0,0,1,-1};

int main(){
   int h,w,k; cin>>h>>w>>k;
   int x1,y1,x2,y2; cin>>x1>>y1>>x2>>y2; x1--; y1--; x2--; y2--;
   vector<vector<char>> g(h,vector<char>(w));
   rep(i,0,h)rep(j,0,w)cin>>g[i][j];
   vector<vector<int>> dist(h,vector<int>(w,inf));
   dist[x1][y1]=0; queue<P> que; que.push(P(x1,y1));
   while(!que.empty()){
      auto [nx,ny]=que.front(); que.pop();
      rep(i,0,4)rep(add,1,k+1){
         int tx=nx+dx[i]*add,ty=ny+dy[i]*add;
         if(tx<0 or tx>=h or ty<0 or ty>=w or g[tx][ty]=='@')break;
         if(dist[tx][ty]<=dist[nx][ny])break;
         if(dist[tx][ty]==inf){
            dist[tx][ty]=dist[nx][ny]+1; que.push(P(tx,ty));
         }
      }
   }
   if(dist[x2][y2]==inf)puts("-1");
   else cout<<dist[x2][y2]<<endl;
   return 0;
}