#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 1000000000LL
#define InfLL 1000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=(n-1);(i)>=(0);(i)--)
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

class Graph_class {
public:
	bool UDLR_and_corner = false;
	int N;
	int M;
	int K;
	int x1, x2, y1, y2;
	vector<vector<int>> xy;

	vector<vector<vector<pii>>> vdist;


	void read_edge();
	void adjini();
	void visited_ini();
	void Dijkstra(pii v_ini);
	void solve();
};

void Graph_class::read_edge() {
	cin >> N >> M >> K;
	cin >> x1 >> y1 >> x2 >> y2;
	x1--;
	x2--;
	y1--;
	y2--;
	xy.resize(N);
	rep(i, N) {
		xy[i].resize(M);
		string S;
		cin >> S;
		rep(j, M) {
			if (S[j] == '.')
				xy[i][j] = 0;
			else
				xy[i][j] = 1;
		}
	}
	return;
}

void Graph_class::adjini() {
	vdist.resize(N);
	rep(i, N) {
		vdist[i].resize(M);
		rep(j, M){
			vdist[i][j].resize(4, make_pair(InfL, InfL));
		}
	}
	return;
}

void Graph_class::Dijkstra(pii v_ini) {
	priority_queue<tuple<int, int, int, int, int>, vector<tuple<int, int, int, int, int> >, greater<tuple<int, int, int, int, int> > > xdist_que;
	// 回数, 歩数, x, y, 向き
	vdist[v_ini.first][v_ini.second][0] = make_pair(0, 0);
	xdist_que.push(make_tuple(0, 0, v_ini.first, v_ini.second, 0));
	
	while (!xdist_que.empty()) {
		tuple<int, int, int, int, int> xdist_que_tmp = xdist_que.top();
		xdist_que.pop();
		int dist_tmp = get<0>(xdist_que_tmp);
		int k_tmp = get<1>(xdist_que_tmp);
		int i0 = get<2>(xdist_que_tmp);
		int j0 = get<3>(xdist_que_tmp);
		int d0 = get<4>(xdist_que_tmp);
		if ((ll)vdist[i0][j0][d0].first * InfL + (ll)vdist[i0][j0][d0].second < (ll)dist_tmp * InfL + (ll)k_tmp)
			continue;
		int dist_new, k_new, i1, j1, d1;
		rep(type, 2){
			dist_new = dist_tmp;
			k_new = k_tmp;
			i1 = i0;
			j1 = j0;
			d1 = d0;
			switch (type)
			{
			case 0:
				// 直進
				switch (d0)
				{
				case 0:
					i1++;
					break;
				case 1:
					i1--;
					break;
				case 2:
					j1++;
					break;
				case 3:
					j1--;
					break;
				}
				if(i1 < 0 || i1 >= N || j1 < 0 || j1 >= M)
					continue;
				if(xy[i1][j1] == 1)
					continue;
				k_new++;
				if(k_new >= K){
					k_new = 0;
					dist_new++;
				}
				break;
			case 1:
				// 回転
				d1++;
				d1 %= 4;
				if(k_new > 0){
					k_new = 0;
					dist_new++;
				}
				break;
			}
			if ((ll)vdist[i1][j1][d1].first * InfL + (ll)vdist[i1][j1][d1].second > (ll)dist_new * InfL + (ll)k_new) {
				vdist[i1][j1][d1].first = dist_new;
				vdist[i1][j1][d1].second = k_new;
				xdist_que.push(make_tuple(dist_new, k_new, i1, j1, d1));
			}
		}
	}
	return;
}

void Graph_class::solve() {
	Dijkstra(make_pair(x1, y1));
	int ans = InfL;
	rep(d, 4){
		int anstmp = vdist[x2][y2][d].first;
		if(vdist[x2][y2][d].second > 0)
		anstmp++;
		ans = min(ans, anstmp);
	}
	if(ans == InfL)
		ans = -1;
	cout << ans << endl;
	return;
}

int main() {
	Graph_class graph;
	graph.read_edge();
	graph.adjini();
	graph.solve();
	return 0;
}


Measured memory_bytes: 82776