#include <bits/stdc++.h>
 
using namespace std;
 
#define int long long
 
#define PB	push_back
#define ALL(x)	(x).begin(), (x).end()
#define ALLR(x)	(x).rbegin(), (x).rend()
#define MP	make_pair
 
#define debug(args...) { string _s = #args; replace(ALL(_s), ',', ' '); stringstream ss(_s); cerr << endl;_debug(ss, args); }
#define _rg auto it = next(v.begin()); it != v.end(); it++
#define _input ostream& operator <<(ostream& out
 
template<typename T, typename U>
_input, const pair<T, U>& p) {
	out << "(" << p.first << ", " << p.second << ")";
	return out;
}
 
#define cont(c) template<typename T> _input, const c<T>& v) { \
					if (v.empty()) return out; \
					out << "[" << *v.begin(); \
					for (_rg) out << ", " << *it; \
					out << "]"; return out; \
				}
				
#define cont2(c) template<typename T, typename U> _input, const c<T, U>& v) { \
					if (v.empty()) return out; \
					out << "[" << *v.begin(); \
					for (_rg) out << ", " << *it; \
					out << "]"; return out; \
				}
 
cont(vector) cont(set) cont(multiset) cont(queue) cont2(map)
 
template<typename T, size_t n, typename= enable_if_t<!is_same<T, char>::value>>
_input, const T(&v)[n]) {
	if (n == 0) return out;
	out << "[" << v[0];
	for (int i = 1; i < (int)n; i++) out << ", " << v[i];
	out  << "]"; return out;
}
 
template<typename T, typename... Ts>
void _debug(stringstream& ss, const T &arg) {
	string name; ss >> name;
	cerr << name << " = " << arg << endl;
}
 
template<typename T, typename... Ts>
void _debug(stringstream& ss, const T& arg, const Ts&... args) {
	string name; ss >> name; 
	cerr << name << " = " << arg << ", ";
	if (is_class<T>::value || is_array<T>::value) cerr << endl;
	_debug(ss, args...);
}
 
#define FAST_IO ios::sync_with_stdio(false); cin.tie(0)
 
typedef pair<int, int> ii;
typedef pair<pair<int, int>, int> iii;
typedef vector<int> vi;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef unsigned long long ull;
 
const int INF = LONG_LONG_MAX/2;
const int NINF = LONG_LONG_MIN/2;
const double PI = 3.141592653589793238;

int H, W, K;
vector<set<int>> rows;
vector<set<int>> cols;
vs grid;
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};

void add(int i, int j) {
	rows[i].insert(j);
	cols[j].insert(i);
}

void rem(int i , int j) {
	rows[i].erase(j);
	cols[j].erase(i);
}

vvi dist;
vvi L, R, U, D;

int32_t main() {
	FAST_IO;
	
	cin >> H >> W >> K;
	int sx, sy, ex, ey;
	cin >> sx >> sy >> ex >> ey;
	--sx; --sy; --ex; --ey;
	
	rows.resize(H); cols.resize(W);
	dist.resize(H);
	for (int i = 0; i < H; i++) {
		dist[i].assign(W, INF);
	}
	
	for (int i = 0; i < H; i++) {
		string s; cin >> s;
		grid.PB(s);
		for (int j = 0; j < W; j++) {
			if (s[j] == '.') {
				add(i, j);
			}
		}
	}
	
	L.resize(H); R.resize(H); U.resize(H); D.resize(H);
	
	for (int i = 0; i < H; i++) {
		L[i].resize(W);
		R[i].resize(W);
		U[i].resize(W);
		D[i].resize(W);
	}
	
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (grid[i][j] != '.') {
				L[i][j] = -1;
			} else {
				if (j > 0 && L[i][j-1] != -1) {
					L[i][j] = L[i][j-1];
				} else {
					L[i][j] = j;
				}
			}
		}
		for (int j = W-1; j >= 0; j--) {
			if (grid[i][j] != '.') R[i][j] = -1;
			else {
				if (j < W-1 && R[i][j+1] != -1) {
					R[i][j] = R[i][j+1];
				} else {
					R[i][j] = j;
				}
			}
		}
	}
	
	for (int j = 0; j < W; j++) {
		for (int i = 0; i < H; i++) {
			if (grid[i][j] != '.') {
				U[i][j] = -1;
			} else {
				if (i > 0 && U[i-1][j] != -1) U[i][j] = U[i-1][j];
				else U[i][j] = i;
			}
		}
		for (int i = H-1; i >= 0; i--) {
			if (grid[i][j] != '.') {
				D[i][j] = -1;
			} else {
				if (i < H-1 && D[i+1][j] != -1) D[i][j] = D[i+1][j];
				else D[i][j] = i;
			}
		}
	}
	
	queue<ii> q;
	q.push({sx, sy});
	dist[sx][sy] = 0; rem(sx, sy);
	while (!q.empty()) {
		int x = q.front().first;
		int y = q.front().second;
		q.pop();
		// L
		{
			int miny = max(y-K, L[x][y]);
			auto it = rows[x].lower_bound(y);
			if (it != rows[x].begin()) {
				it--;
				vii removals;
				while ((*it) >= miny) {
					removals.PB({x, (*it)});
					if (it == rows[x].begin()) break;
					it--;
				}
				for (ii sq: removals) {
					dist[sq.first][sq.second] = dist[x][y]+1;
					q.push(sq);
					rem(sq.first, sq.second);
				}
			}
		}
		
		// R
		{
			int maxy = min(y+K, R[x][y]);
			auto it = rows[x].upper_bound(y);
			if (it != rows[x].end()) {
				vii removals;
				while ((*it) <= maxy) {
					removals.PB({x, (*it)});
					it++;
					if (it == rows[x].end()) break;
				}
				for (ii sq: removals) {
					dist[sq.first][sq.second] = dist[x][y] + 1;
					q.push(sq);
					rem(sq.first, sq.second);
				}
			}
		}
		
		// U
		{
			int minx = max(x-K, U[x][y]);
			auto it = cols[y].lower_bound(x);
			if (it != cols[y].begin()) {
				it--;
				vii removals;
				while ((*it) >= minx) {
					removals.PB({(*it), y});
					if (it == cols[y].begin()) break;
					it--;
				}
				for (ii sq: removals) {
					dist[sq.first][sq.second] = dist[x][y] + 1;
					q.push(sq);
					rem(sq.first, sq.second);
				}
			}
		}
		
		// D
		{
			int maxx = min(x+K, D[x][y]);
			auto it = cols[y].lower_bound(x);
			if (it != cols[y].end()) {
				vii removals;
				while ((*it) <= maxx) {
					removals.PB({(*it), y});
					it++;
					if (it == cols[y].end()) break;
				}
				for (ii sq: removals) {
					dist[sq.first][sq.second] = dist[x][y] + 1;
					q.push(sq);
					rem(sq.first, sq.second);
				}
			}
		}
	}
	
	if (dist[ex][ey] >= INF) dist[ex][ey] = -1;
	cout << dist[ex][ey] << endl;
}
// g++ -Wall -Wextra -Wshadow -fsanitize=undefined -std=c++17


Measured memory_bytes: 183496