#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;

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

int main()
{
  int h,w,k;
  cin>>h>>w>>k;
  pair<int,int> start,goal;
  cin>>start.first>>start.second;
  start.first--;start.second--;
  cin>>goal.first>>goal.second;
  goal.first--;goal.second--;
  vector<string> field(h);
  for (int i = 0; i < h; ++i)
  {
    cin>>field[i];
  }
  vector<vector<ll>> distance(h,vector<ll>(w,-1));
  vector<vector<bool>> seen(h,vector<bool>(w,false));
  distance[start.first][start.second]=0;
  queue<pair<int,int>> next;
  next.push(start);
  seen[start.first][start.second]=true;
  while(!next.empty())
  {
    int x=next.front().first;
    int y=next.front().second;
    next.pop();
    for (int i = 0; i < 4; ++i)
    {
      for (int j = 1; j <= k; ++j)
      {
        int nx=x+j*dx[i],ny=y+j*dy[i];
        if(nx<0||nx>=h||ny<0||ny>=w) break;
        if(field[nx][ny]=='@') break;
        if(seen[nx][ny]) 
        {
          if(distance[nx][ny]<distance[x][y]+1) break;
          distance[nx][ny]=min(distance[nx][ny],distance[x][y]+1);
          continue;
        }
        else distance[nx][ny]=distance[x][y]+1;
        seen[nx][ny]=true;
        next.push({nx,ny});
      }
    }
  }

  cout<<distance[goal.first][goal.second]<<endl;
}