#include <bits/stdc++.h>

using namespace std;

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

int main() {
	int n, m, k;
	cin >> n >> m >> k;

	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;

	vector< vector<long long> > arr(n, vector<long long>(m, -1));
	auto dist = arr;

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			char c; cin >> c;
			arr[i][j] = (c != '.');
		}
	}

	queue< pair<int, int> > q;
	x1--; y1--;
	x2--; y2--;

	q.push({x1, y1});
	dist[x1][y1] = 0;

	while (!q.empty()) {
		pair<int, int> u = q.front(); q.pop();
		for (int i = 0; i < 4; i++) {
			for (int j = 1; j <= k; j++) {
				int tx = u.first + dx[i] * j; int ty = u.second + dy[i] * j;
				if (tx == n || ty == m || tx < 0 || ty < 0 || arr[tx][ty] || dist[tx][ty] != -1 && dist[tx][ty] <= dist[u.first][u.second])
					break;
				if (dist[tx][ty] == -1) dist[tx][ty] = dist[u.first][u.second] + 1, q.push({tx, ty});
			}
		}
	}

	cout << dist[x2][y2];
	return 0;
}
