#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <utility>
using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pi;

const int dx[4] = {  0, 1, 0, -1 };
const int dy[4] = { -1, 0, 1,  0 };
const int INF = (int)(2e+9);

int H, W, K;
int sy, sx, gy, gx;
vector<string> S;
vector<vi> d;

void input_init(void) {
	cin >> H >> W >> K;
	cin >> sy >> sx >> gy >> gx;
	S.resize(H + 2);
	S[0] = S[H + 1] = string(W + 2, '@');
	for (int j = 1; j <= H; ++j) {
		string str;
		cin >> str;
		S[j] = "@" + str + "@";
	}
	d.resize(H + 2, vi(W + 2, INF));
}

int bfs() {
	queue<pi> que;
	que.push(make_pair(sx, sy));
	d[sy][sx] = 0;
	while (que.size()) {
		pi p = que.front();
		que.pop();
		if (p.first == gx && p.second == gy)
			break;
		for (int i = 0; i < 4; ++i) {
			for (int k = 1; k <= K; ++k) {
				int nx = p.first + dx[i] * k;
				int ny = p.second + dy[i] * k;
				if (S[ny][nx] == '@')
					break;
				if (d[ny][nx] <= d[p.second][p.first])
					break;
				if (d[ny][nx] > d[p.second][p.first] + 1) {
					que.push(make_pair(nx, ny));
					d[ny][nx] = d[p.second][p.first] + 1;
				}
			}
		}
	}
	return d[gy][gx];
}

int main(void) {
	input_init();
	int ans = bfs();
	if (ans == INF)
		ans = -1;
	cout << ans << '\n';
	return 0;
}
