#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <list>
#include <ctime>
#include <sstream>
#include <queue>
#include <stack>
#include <random>
#include <bitset>
#include <numeric>
#include <cassert>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
#define rep(x, b, e) for(int x=(b); x<(e); ++x)
#define ford(x, b, e) for(int x=((int)(b))-1; x>=(e); --x)
#define all(c) c.begin(),c.end()
#define sz(x) ((int)((x).size()))
#define pb push_back
#define st first
#define nd second
#define mp(x,y) make_pair(x,y)
typedef short int sint;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it) {
	*this << ((it != d.b) ? ", " : "") << *it;
  }
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

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


int main() {
	ios_base::sync_with_stdio(false);
	int h,w,k;
	cin >> h >> w >> k;
	pii s, e;
	cin >> s.st >> s.nd >> e.st >> e.nd;
	--s.st; --s.nd; --e.st; --e.nd;
	vector<string> inp(h);
	rep(i,0,h) cin >> inp[i];
	queue<pair<pii, pii>> q1, q2;
	vector<vector<vector<int>>> dist(h, vector<vector<int>>(w, vector<int>(D, h*w)));
	auto ok = [&](int x, int y) {
		// printf("check: %d, %d\n", x, y);
		return x >=0 && x < h && y >= 0 && y < w && inp[x][y] == '.';
	};
	rep(i,0,D) {
		dist[s.st][s.nd][i] = 0;
		int ni = s.st + dx[i], nj = s.nd + dy[i];
		if (ok(ni, nj)) {
			// printf("adding: %d, %d,  %d, %d\n", ni, nj, i, 1);
			q1.push({{ni, nj}, {i, 1}});
			dist[ni][nj][i] = 1;
		}
	}
	int dl = 1;
	while (true) {
		// printf("current dist: %d\n", dl);
		while (!q1.empty()) {
			auto cur = q1.front(); q1.pop();
			auto pos = cur.st, state = cur.nd;
			// printf("on pos: %d, %d with state: %d, %d\n", pos.st, pos.nd, state.st, state.nd);
			if (pos == e) {
				cout << dl << endl;
				return 0;
			}
			if (state.nd < k) {
				int ni = pos.st + dx[state.st], nj = pos.nd + dy[state.st];
				// printf("\t extending brush to: %d, %d,  state: %d, %d\n", ni, nj, state.st, state.nd + 1);
				if (ok(ni, nj) && dist[ni][nj][state.st] > dl) {
					dist[ni][nj][state.st] = dl;
					q1.push({{ni, nj}, {state.st, state.nd + 1}});
				}
			}
			rep(i,0,D) {
				int ni = pos.st + dx[i], nj = pos.nd + dy[i];
				if (!ok(ni, nj)) {
					continue;
				}
				if (dist[ni][nj][i] > dl + 1) {
					// printf("\tnext brush to: %d, %d, with : %d, %d\n", ni,nj,i,1);
					dist[ni][nj][i] = dl + 1;
					q2.push({{ni, nj}, {i, 1}});
				}
			}
		}
		if (q2.empty()) {
			break;
		}
		swap(q1, q2);
		++dl;
	}
	cout << -1 << endl;
}

Measured memory_bytes: 113620