#pragma GCC optimize("O3")
#pragma GCC target("avx,avx2")
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <cmath>
#include <iomanip>
#include <cstdio>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <bitset>
#include <cstring>
#include <unordered_map>
using namespace std;
typedef int ll;
#define endl '\n'
typedef pair<ll, pair<ll, ll>> pll;
priority_queue<pll, vector<pll>, greater<pll>> q;
ll n, r, c;
void check(int x, int y, int d, vector<vector<ll>> &dist, vector<string> &a, vector<set<ll>> &st, set<ll> &row){
if(x >= 1 && y >= 1 && x <= r && y <= c && d < dist[x][y] && a[x][y] == '.'){
dist[x][y] = d;
q.push({d, {x, y}});
st[x].erase(y);
if(st[x].empty())
row.erase(x);
}
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> r >> c >> n;
ll s1, s2, f1, f2;
cin >> s1 >> s2 >> f1 >> f2;
vector<string> a(r + 1);
for(int i = 1; i <= r; i++){
cin >> a[i];
a[i] = "#" + a[i];
}
vector<set<ll>> st(r + 1);
set<ll> row;
for(int i = 1; i <= r; i++){
for(int j = 1; j <= c; j++){
if(i != s1 || j != s2)
st[i].insert(j);
}
if(!st[i].empty())
row.insert(i);
}
q.push({0, {s1, s2}});
vector<vector<bool>> used(r + 1, vector<bool> (c + 1));
vector<vector<ll>> dist(r + 1, vector<ll> (c + 1, 1e9));
dist[s1][s2] = 0;
vector<int> roll, roll2;
ll x2 = 0;
while(!q.empty()){
auto v = q.top();
q.pop();
int x = v.second.first, y = v.second.second;
if(used[x][y])
continue;
if(x == f1 && y == f2)
break;
used[x][y] = 1;
check(x - 1, y, v.first, dist, a, st, row);
check(x + 1, y, v.first, dist, a, st, row);
check(x, y - 1, v.first, dist, a, st, row);
check(x, y + 1, v.first, dist, a, st, row);
auto p = row.lower_bound(x - n);
while(p != row.end() && (*p) <= x + n){
x2 = *p;
auto u = st[x2].lower_bound(y - n);
roll.clear();
while(u != st[x2].end() && (*u) <= y + n){
if((abs(x2 - x) < n || abs(y - *u) < n) && v.first + 1 < dist[x2][(*u)]){
dist[x2][*u] = v.first + 1;
q.push({v.first + 1, {x2, *u}});
roll.push_back(*u);
}
u++;
}
for(auto i: roll){
st[x2].erase(i);
}
if(st[x2].empty())
roll2.push_back(x2);
p++;
}
for(auto i: roll2)
row.erase(i);
roll2.clear();
}
cout << dist[f1][f2] << endl;
return 0;
}