#include <bits/stdc++.h>
using namespace std;
						
#define fast_cin() ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define endl '\n'
#define int long long

int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, -1, 1};
				
int32_t main() {
	fast_cin();  
	int n, m, k; cin >> n >> m >> k;
	int x1, x2, y1, y2; cin >> x1 >> y1 >> x2 >> y2;
	--x1, --x2, --y1, --y2;
	string s[n + 1];
	for (int i = 0; i < n; ++i) cin >> s[i];
	queue<pair<int, int> > q;
	q.push({x1, y1});
	int dist[n + 1][m + 1];
	bool vis[n + 1][m + 1];
	memset(vis, false, sizeof vis);
	memset(dist, 5, sizeof dist);
	dist[x1][y1] = 0;
	auto valid = [&](int x, int y) {
		return x >= 0 and x < n and y >= 0 and y < m and s[x][y] != '@';
	};
	while (!q.empty()) {
		auto [x, y] = q.front();
		q.pop();
		vis[x][y] = true;
		for (int dir = 0; dir < 4; ++dir) {
			for (int len = 1; len <= k; ++len) {
				int nx = x + dx[dir] * len, ny = y + dy[dir] * len;
				if (!valid(nx, ny)) break;
				if (vis[nx][ny] and dist[nx][ny] < dist[x][y] + 1) break;
				if (vis[nx][ny]) {
					assert(dist[nx][ny] == dist[x][y] + 1);
					continue;
				}
				dist[nx][ny] = dist[x][y] + 1;
				vis[nx][ny] = true;
				q.push({nx, ny});
			}
		}
	}
	int ans = dist[x2][y2];
	if (!vis[x2][y2]) ans = -1;
	cout << ans << endl;
	return 0;
}