#include <bits/stdc++.h>
#define bug1(x) cout<<#x<<" = "<<x<<endl
#define bug2(x,y) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<endl
#define bug3(x,y,z) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<endl
#define bug4(x,y,z,m) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<" "<<#m<<" = "<<m<<endl

using namespace std;

class Debugger {
public:
	template<typename T>
	void printVector(vector<T> const &vec, bool printSize=true){
		if(printSize){
			cout << vec.size() << endl;
		}
		for(auto &elem : vec){
			cout << elem << " ";
		}
		cout << endl;
	}

	template<typename T>
	void printMatrix(vector<vector<T>> const &matrix){
		cout << matrix.size()<< " ";
		if(!matrix.empty()){
			cout << matrix[0].size();
		}
		cout << endl; 
		for(auto &vec : matrix){
			printVector(vec, false);
		}
		cout << endl;
	}
};

const int INF = 1e9;
const int MAXN = 1000005;
#define ll long long

set<int> colsInRows[MAXN];
set<int> rowsInCols[MAXN];

class TaskF {
private:
	Debugger debugger;

public:
	void solveOne(int it){
		int rows, cols, limit;
		cin >> rows >> cols >> limit;
		int fromX, fromY, toX, toY;
		cin >> fromX >> fromY >> toX >> toY;
		fromX--; fromY--;
		toX--; toY--;
		vector<string> tab(rows);
		vector<vector<int>> leftLimForRows(rows, vector<int>(cols, -1)), rightLimForRows(rows, vector<int>(cols, cols));
		for(int i = 0; i < rows; i++){
			cin >> tab[i];
			for(int j = 0; j < cols; j++){
				colsInRows[i].insert(j);	
				rowsInCols[j].insert(i);
				if(tab[i][j] == '@'){
					leftLimForRows[i][j] = j;
				}else{
					if(j > 0){
						leftLimForRows[i][j] = leftLimForRows[i][j-1];
					}
				}
			}
			for(int j = cols-1; j >= 0; j--){
				if(tab[i][j] == '@'){
					rightLimForRows[i][j] = j;
				}else{
					if(j+1 < cols){
						rightLimForRows[i][j] = rightLimForRows[i][j+1];
					}
				}
			}
		}
		vector<vector<int>> upLimForCols(rows, vector<int>(cols, -1)), downLimForCols(rows, vector<int>(cols, rows));
		for(int j = 0; j < cols; j++){
			for(int i = 0; i < rows; i++){
				if(tab[i][j] == '@'){
					upLimForCols[i][j] = i;
				}else{
					if(i > 0){
						upLimForCols[i][j] = upLimForCols[i-1][j];
					}
				}
			}
			for(int i = rows-1; i >= 0; i--){
				if(tab[i][j] == '@'){
					downLimForCols[i][j] = i;
				}else{
					if(i+1 < rows){
						downLimForCols[i][j] = downLimForCols[i+1][j];
					}
				}
			}
		}
		//debugger.printMatrix(leftLimForRows);
		//debugger.printMatrix(rightLimForRows);
		//debugger.printMatrix(upLimForCols);
		//debugger.printMatrix(downLimForCols);


		vector<vector<int>> dist(rows, vector<int>(cols, INF));
		queue<pair<int,int>> q;
		q.push({fromX, fromY});
		dist[fromX][fromY] = 0;
		colsInRows[fromX].erase(fromY);
		rowsInCols[fromY].erase(fromX);
		while(!q.empty()){
			auto curr = q.front(); q.pop();
			int x = curr.first;
			int y = curr.second;
			//bug3(x, y, dist[x][y]);
			auto b = colsInRows[x].lower_bound(max(y-limit,leftLimForRows[x][y]+1) );
			auto e = colsInRows[x].upper_bound(min(y+limit, rightLimForRows[x][y]-1) );
			while(b != e){
				int xnew = x;
				int ynew = *b;
				if(1 + dist[x][y] < dist[xnew][ynew]){
					dist[xnew][ynew] = 1 + dist[x][y];
					q.push({xnew, ynew});
				}
				b++;
			}
			b = colsInRows[x].lower_bound(max(y-limit,leftLimForRows[x][y]+1) );
			e = colsInRows[x].upper_bound(min(y+limit, rightLimForRows[x][y]-1) );
			colsInRows[x].erase(b, e);

			b = rowsInCols[y].lower_bound(max(x-limit, upLimForCols[x][y]+1)  );
			e = rowsInCols[y].upper_bound(min(x+limit, downLimForCols[x][y]-1) );
			while(b != e){
				int xnew = (*b);
				int ynew = y;
				if(1 + dist[x][y] < dist[xnew][ynew]){
					dist[xnew][ynew] = 1 + dist[x][y];
					q.push({xnew, ynew});
				}
				b++;
			}
			b = rowsInCols[y].lower_bound(max(x-limit, upLimForCols[x][y]+1)  );
			e = rowsInCols[y].upper_bound(min(x+limit, downLimForCols[x][y]-1) );
			rowsInCols[y].erase(b, e);
		}
		if(dist[toX][toY] >= INF){
			cout << -1 << endl;
			return;
		}
		cout << dist[toX][toY] << endl;
	}

	void solve(){
		int tc = 1;
		for(int it = 1; it <= tc; it++){
			solveOne(it);
		}
	}
};


int main(){
	ios_base::sync_with_stdio(false);
	TaskF solver;
	solver.solve();
	return 0;
}


Measured memory_bytes: 215112