/*input
3 3 1
2 1 2 3
.@.
.@.
.@.
*/

// Nihesh Anderson - knandy

#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;

typedef long long ll;
typedef long double ld;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; // find_by_order, order_of_key
ll MOD=1000000007;

#define endl '\n'
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
ll INF = 2000000000000000001;
long double EPS = 1e-9;
ll power(ll a, ll n, ll md){if(n==0){return 1;}else{int res=power(a,n/2,md);res=(res*res)%md;if(n%2!=0){res=(res*a)%md;}return res;}}
random_device rndm;
mt19937 grndm(rndm());
void mix(int* a, int* b){shuffle(a,b,grndm);}

map<pair<int, int>, int> ans;

int main(){
	fast_cin();
	// freopen("input.in","r",stdin);
	// freopen("output.out","w",stdout);
	int h, w, k;
	cin >> h >> w >> k;
	pair<int, int> src, dst;
	vector<string> v(h);
	vector<vector<int> > prefx(h + 1, vector<int>(w + 1)), prefy(h + 1, vector<int>(w + 1));
	cin >> src.first >> src.second >> dst.first >> dst.second;
	src.first--;
	src.second--;
	dst.first--;
	dst.second--;
	for(int i = 0; i < h; i++) {
		cin >> v[i];
	}
	for(int i = 0; i < h; i++) {
		for(int j = 0; j < w; j++) {
			if(v[i][j] == '.') {
				prefx[i][j + 1] = prefx[i][j];
			}
			else {
				prefx[i][j + 1] = 1 + prefx[i][j];
			}
		}
	}
	for(int j = 0; j < w; j++) {
		for(int i = 0; i < h; i++) {
			if(v[i][j] == '.') {
				prefy[i + 1][j] = prefy[i][j];
			}
			else {
				prefy[i + 1][j] = 1 + prefy[i][j];
			}
		}
	}
	vector<set<int> > visx(h), visy(w);
	for(int i = 0; i < h; i++) {
		for(int j = 0; j < w; j++) {
			visx[i].insert(j);
			visy[j].insert(i);
		}
	}
	visx[src.first].erase(src.second);
	visy[src.second].erase(src.first);
	queue<pair<pair<int, int>, int> > q;
	q.push({src, 0});
	while(q.size()) {
		auto now = q.front();
		q.pop();
		ans[now.first] = now.second;
		auto it = visx[now.first.first].lower_bound(now.first.second);
		while(it != visx[now.first.first].end() && *it <= now.first.second + k && !(prefx[now.first.first][*it + 1] - prefx[now.first.first][now.first.second])) {
			pair<pair<int,int>, int> nxt = make_pair(make_pair(now.first.first, *it), now.second + 1);
			q.push(nxt);
			visx[nxt.first.first].erase(nxt.first.second);
			visy[nxt.first.second].erase(nxt.first.first);
			it = visx[now.first.first].lower_bound(now.first.second);
		}
		it = visx[now.first.first].lower_bound(now.first.second);
		while(it != visx[now.first.first].begin() && *(--it) >= now.first.second - k && !(-prefx[now.first.first][*it] + prefx[now.first.first][now.first.second + 1])) {
			pair<pair<int,int>, int> nxt = make_pair(make_pair(now.first.first, *it), now.second + 1);
			q.push(nxt);
			visx[nxt.first.first].erase(nxt.first.second);
			visy[nxt.first.second].erase(nxt.first.first);
			it = visx[now.first.first].lower_bound(now.first.second);
		}

		it = visy[now.first.second].lower_bound(now.first.first);
		while(it != visy[now.first.second].end() && *it <= now.first.first + k && !(prefy[*it + 1][now.first.second] - prefy[now.first.first][now.first.second])) {
			pair<pair<int,int>, int> nxt = make_pair(make_pair(*it, now.first.second), now.second + 1);
			q.push(nxt);
			visx[nxt.first.first].erase(nxt.first.second);
			visy[nxt.first.second].erase(nxt.first.first);
			it = visy[now.first.second].lower_bound(now.first.first);
		}
		it = visy[now.first.second].lower_bound(now.first.first);
		while(it != visy[now.first.second].begin() && *(--it) >= now.first.first - k && !(-prefy[*it][now.first.second] + prefy[now.first.first + 1][now.first.second])) {
			pair<pair<int,int>, int> nxt = make_pair(make_pair(*it, now.first.second), now.second + 1);
			q.push(nxt);
			visx[nxt.first.first].erase(nxt.first.second);
			visy[nxt.first.second].erase(nxt.first.first);
			it = visy[now.first.second].lower_bound(now.first.first);
		}
	}	
	if(ans[dst] == 0) {
		cout << "-1" << endl;
	}
	else {
		cout << ans[dst] << endl;
	}
	return 0;
}

Measured memory_bytes: 160560