#include <bits/stdc++.h>                                           
 
//#define int long long
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
 
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define s second
#define f first
 
 
using namespace std;



typedef pair < long long, long long > pll;
typedef unsigned long long ull;
typedef pair < int, int > pii;
typedef vector < pii > vpii;
typedef vector < int > vi;
typedef long double ldb;
typedef long long ll;
typedef double db;
 
 
const int inf = 1e9, maxn = 4e5 + 148, mod = 1e9 + 7, N = 1e6 + 11;
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 466;
const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);
const db eps = 1e-12, pi = 3.14159265359;
const ll INF = 1e18;

 
int n, m, xa, ya, xb, yb, k;
set < int > X[N], Y[N];
vi bad[N], d[N];
queue < pii > q;
char c;

void add (int x, int y, int c) {
//	cerr << x << ' ' << y << endl;
	d[x][y] = c;
	q.push({x, y});
	X[x].erase(y);
	Y[y].erase(x);
}

int get (int xa, int ya, int xb, int yb) {
	if (xa < xb)
		swap(xa, xb);
	
	if (ya < yb)
		swap(ya, yb);
	
	--xb, --yb;
	return bad[xa][ya] - bad[xa][yb] - bad[xb][ya] + bad[xb][yb];
}

bool check (int x, int y, int tox, int toy) {
	if (abs(x - tox) > k || abs(y - toy) > k)
		return 0;
	return !get(x, y, tox, toy);
}

main () {
	scanf("%d%d%d", &n, &m, &k);	
	scanf("%d%d%d%d", &xa, &ya, &xb, &yb);
	bad[0].resize(m + 1);

	for (int i = 1; i <= n; ++i) {
		bad[i].resize(m + 1);
		d[i].resize(m + 1);
		scanf("\n");
		for (int j = 1; j <= m; ++j) {
			scanf("%c", &c);
			if (c == '@')
				bad[i][j] = 1;				
			bad[i][j] += bad[i - 1][j] + bad[i][j - 1] - bad[i - 1][j - 1];
		}
	}

	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= m; ++j)  {
			d[i][j] = -1; 
			X[i].insert(j);
			Y[j].insert(i);
		}

	add(xa, ya, 0);

	while (sz(q)) {
		int x = q.front().f, y = q.front().s;
//		cerr << x << ' ' << y << endl;
		q.pop();
		
		while (1) {
//			cerr << "hello\n";
			if (!sz(X[x]) || *X[x].rbegin() < y)
				break;

			int toy = *X[x].lower_bound(y);
//			cerr << x << ' ' << y << endl;
//			cerr << sz(X[x]) << ' ' << *X[x].rbegin() << ' ' << toy << endl << endl;
			if (check(x, y, x, toy))
				add(x, toy, d[x][y] + 1);
			else
				break;	
		}
		
		while (1) {
			if (!sz(Y[y]) || *Y[y].rbegin() < x)
				break;
			int tox = *Y[y].lower_bound(x);
			if (check(tox, y, x, y))
				add(tox, y, d[x][y] + 1);
			else
				break;	
		}

		while (1) {
			if (!sz(X[x]) || *X[x].begin() > y)
				break;
			auto i = X[x].lower_bound(y);
			--i;
			int toy = *i;
			if (check(x, y, x, toy))
				add(x, toy, d[x][y] + 1);
			else
				break;	
		}		
		while (1) {
			if (!sz(Y[y]) || *Y[y].begin() > x)
				break;
			auto i = Y[y].lower_bound(x);
			--i;
			int tox = *i;
			if (check(tox, y, x, y))
				add(tox, y, d[x][y] + 1);
			else
				break;	
		}
	}


	cout << d[xb][yb] << endl;
}



Measured memory_bytes: 249312