#include <bits/stdc++.h>
using namespace std;

vector<pair<int,int>> dir = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int h, w, k;
	cin >> h >> w >> k;
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	--x1; --y1; --x2; --y2;
	vector<string> grid(h);
	for (int i = 0; i < h; ++i)
		cin >> grid[i];
	auto valid = [&](const pair<int, int>& p){ return p.first >= 0 && p.first < h && p.second >= 0 && p.second < w; };
	
	vector<vector<int>> dist(h, vector<int>(w, 1e9));
	auto bfs = [&](){
		queue<pair<int, int>> q;
		vector<vector<bool>> vis(h, vector<bool>(w));
		q.emplace(x1, y1);
		dist[x1][y1] = 0;
		vis[x1][y1] = 1;
		while (!q.empty()){
			auto u = q.front(); q.pop();
			for (int j = 0; j < 4; ++j){
				for (int i = 1; i <= k; ++i){
					int nr = u.first + i * dir[j].first;
					int nc = u.second + i * dir[j].second;
					if (!valid({nr, nc})) continue;
					if (grid[nr][nc] == '@' || dist[nr][nc] <= dist[u.first][u.second]) break;
					if (vis[nr][nc]) continue;
					dist[nr][nc] = dist[u.first][u.second] + 1;
					if (nr == x2 && nc == y2) return dist[nr][nc];
					vis[nr][nc] = 1;
					q.emplace(nr, nc);
				}
			}
		}
		return -1;
	};
	cout << bfs() << '\n';
}
