#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")

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

#define pb push_back
#define F first
#define S second
#define f(i,a,b)  for(int i = a; i < b; i++)
//#define endl '\n'

using ll = long long;
using db = long double;
using ii = pair<int, int>;

const int N = 2e5 + 5, LG = 19, MOD = 998244353;
const int SQ =225;
const long double EPS = 1e-6;
vector<set<int>> row, col;
vector<set<int>> frow, fcol;
int h, w, k, xx1, yy1, xx2, yy2;
vector<vector<char>> grid;
vector<vector<int>> dist;
int32_t main(){
#ifdef ONLINE_JUDGE
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif

  cin >> h >> w >> k;
  cin >> xx1 >> yy1 >> xx2 >> yy2;
  --xx1,--xx2,--yy1,--yy2;

  row.resize(h);
  col.resize(w);
  frow.resize(h);
  fcol.resize(w);

  grid.assign(h, vector<char>(w));
  dist.assign(h, vector<int>(w, -1));
  f(i,0,h)row[i].insert(-1e9), row[i].insert(1e9);
  f(i,0,w)col[i].insert(-1e9), col[i].insert(1e9);
  f(i,0,h)frow[i].insert(-1e9), frow[i].insert(1e9);
  f(i,0,w)fcol[i].insert(-1e9), fcol[i].insert(1e9);
  f(i,0,h)
    f(j,0,w){
      cin >> grid[i][j];
      if(grid[i][j] == '.'){
        row[i].insert(j);
        col[j].insert(i);
      } else {
        frow[i].insert(j);
        fcol[j].insert(i);
      }
    }

  dist[xx1][yy1] = 0;
  queue<ii> q;
  q.push(ii(xx1,yy1));
  row[xx1].erase(yy1);
  col[yy1].erase(xx1);

  while(q.size()){

    auto cur = q.front();
    q.pop();
//    cout << cur.F << ' ' << cur.S << ' ' << dist[cur.F][cur.S] << endl;
    ///move right;
    auto it = row[cur.F].upper_bound(cur.S);
    if(*frow[cur.F].upper_bound(cur.S) > *it)
    while(*it - cur.S <= k){
      auto nxt = next(it);
      bool f = (*frow[cur.F].upper_bound(*it)) < *nxt;
      q.push(ii(cur.F,*it));
      dist[cur.F][*it] = dist[cur.F][cur.S] + 1;
      col[*it].erase(cur.F);
      row[cur.F].erase(it);
      if(f)break;
      it = nxt;
    }

    ///move left;
    it = --row[cur.F].upper_bound(cur.S);
    if(*(--frow[cur.F].upper_bound(cur.S)) < *it)
    while(cur.S - *it <= k){
      auto nxt = prev(it);
      bool f = (*(--frow[cur.F].upper_bound(*it))) > *nxt;
      q.push(ii(cur.F,*it));
      dist[cur.F][*it] = dist[cur.F][cur.S] + 1;
      col[*it].erase(cur.F);
      row[cur.F].erase(it);
      if(f)break;
      it = nxt;
    }

    ///move down;
    it = col[cur.S].upper_bound(cur.F);
    if(*fcol[cur.S].upper_bound(cur.F) > *it)
    while(*it - cur.F <= k){
      auto nxt = next(it);
      bool f = (*fcol[cur.S].upper_bound(*it)) < *nxt;
      q.push(ii(*it, cur.S));
      dist[*it][cur.S] = dist[cur.F][cur.S] + 1;
      row[*it].erase(cur.S);
      col[cur.S].erase(it);
      if(f)break;
      it = nxt;
    }

    ///move up;
    it = --col[cur.S].upper_bound(cur.F);
    if(*(--fcol[cur.S].upper_bound(cur.F)) < *it)
    while(cur.F - *it <= k){
      auto nxt = prev(it);
      bool f = (*(--fcol[cur.S].upper_bound(*it))) > *nxt;
      q.push(ii(*it, cur.S));
      dist[*it][cur.S] = dist[cur.F][cur.S] + 1;
      row[*it].erase(cur.S);
      col[cur.S].erase(it);
      if(f)break;
      it = nxt;
    }


  }

  cout << dist[xx2][yy2] << endl;

  return 0;
}


Measured memory_bytes: 383176