#include <stdio.h>

char buffer[4567890];
int buffer2[1234567];

int H, W, K;
int x1, y1, x2, y2;
char* c[1234567];
int* cost[1234567];

int qs, qe;
int q[1234567][2];

int main(void) {
	int i;
	if (fgets(buffer, sizeof(buffer), stdin) == NULL) return 1;
	if (sscanf(buffer, "%d%d%d", &H, &W, &K) != 3) return 1;
	if (fgets(buffer, sizeof(buffer), stdin) == NULL) return 1;
	if (sscanf(buffer, "%d%d%d%d", &x1, &y1, &x2, &y2) != 4) return 1;
	for (i = 0; i < H; i++) {
		c[i] = &buffer[(W + 3) * i];
		cost[i] = &buffer2[W * i];
		if (fgets(c[i], W + 3, stdin) == NULL) return 1;
	}
	q[0][0] = x1 - 1;
	q[0][1] = y1 - 1;
	cost[x1 - 1][y1 - 1] = 1;
	qs = 0;
	qe = 1;
	while (qs < qe) {
		int cy = q[qs][0], cx = q[qs][1];
		int cc = cost[cy][cx];
		qs++;
		for (i = 1; i <= K && cx - i >= 0 && c[cy][cx - i] != '@' && (cost[cy][cx - i] == 0 || cost[cy][cx - i] > cc); i++) {
			if (cost[cy][cx - i] == 0) {
				q[qe][0] = cy;
				q[qe][1] = cx - i;
				qe++;
			}
			cost[cy][cx - i] = cc + 1;
		}
		for (i = 1; i <= K && cx + i < W && c[cy][cx + i] != '@' && (cost[cy][cx + i] == 0 || cost[cy][cx + i] > cc); i++) {
			if (cost[cy][cx + i] == 0) {
				q[qe][0] = cy;
				q[qe][1] = cx + i;
				qe++;
			}
			cost[cy][cx + i] = cc + 1;
		}
		for (i = 1; i <= K && cy - i >= 0 && c[cy - i][cx] != '@' && (cost[cy - i][cx] == 0 || cost[cy - i][cx] > cc); i++) {
			if (cost[cy - i][cx] == 0) {
				q[qe][0] = cy - i;
				q[qe][1] = cx;
				qe++;
			}
			cost[cy - i][cx] = cc + 1;
		}
		for (i = 1; i <= K && cy + i < H && c[cy + i][cx] != '@' && (cost[cy + i][cx] == 0 || cost[cy + i][cx] > cc); i++) {
			if (cost[cy + i][cx] == 0) {
				q[qe][0] = cy + i;
				q[qe][1] = cx;
				qe++;
			}
			cost[cy + i][cx] = cc + 1;
		}
	}
	printf("%d\n", cost[x2 - 1][y2 - 1] - 1);
	return 0;
}
