#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());
using namespace std;

// #define int long long
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
ll mod = (1000000007LL);
inline ll Mod(ll a, ll b){return (a%b);}
inline ll poww(ll a, ll b){ll res = 1;while (b > 0){if(b & 1) res = (res * a)%mod;a = (a * a)%mod;b >>= 1;}return res;}
ll gcd (ll a, ll b) { while (b) { a %= b,swap(a, b);}return a;}
void read(vector<int> &w, int n){w.resize(n);for(int i = 0; i < n; i++) cin>>w[i];}
void print(vector<int> &w){for(int i =0; i < sz(w); i++){if(i == sz(w) - 1) cout<<w[i]<<"\n";else cout<<w[i]<<" ";}}
int prodmod(vector<int> w);
int summod(vector<int> w);
///CUIDADO COM MAXN
#define N 300050

int n, m, q, k, v[N], ans;
pii w[N];
string s;
struct node{
	int x, y;
	int dist, resta, dir;
	bool operator<(const node & NODE) const{
		if(dist != NODE.dist) return dist < NODE.dist;
		return resta > NODE.resta;
	}
	bool operator>(const node & NODE) const{
		if(dist != NODE.dist) return dist > NODE.dist;
		return resta < NODE.resta;
	}
};
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
int32_t main(){
	ios::sync_with_stdio(false); cin.tie(0);
	cin>>n>>m>>k;
	int xi, yi, x2, y2;
	cin>>xi>>yi>>x2>>y2;
	vector<vector<char>> mat(n + 1);
	for(int i=1;i<=n;i++){
		mat[i].resize(m + 1);
		for(int j= 1; j <= m; j++){
			cin>>mat[i][j];
		}
	}
	//0 ->down
	//1 ->up
	//2 ->righ
	//3 ->left
	vector< vector<node> > dist[5];
	for(int a=0;a<5;a++){
		dist[a].resize(n + 1);
		for(int i = 1; i <= n; i++) dist[a][i].resize(m+1);
		for(int i = 1;i<=n;i++){
			for(int j=1;j<=m;j++){
				node INUTIL;
				INUTIL.x=i,INUTIL.y=j,INUTIL.dir=a,INUTIL.dist = 200000000, INUTIL.resta=0;
				dist[a][i][j] = INUTIL;
			}
		}
	}
	
	priority_queue<node, vector<node>, greater<node> > fila;
	set<node> vis;
	node ST;
	for(int p = 0; p < 4; p++){
		ST.x=xi, ST.y =yi, ST.resta =0, ST.dir=p, ST.dist = 0;
		dist[p][xi][yi]= ST;
		fila.push(ST);
	}
	int ans = 200000000;
	while(!fila.empty()){
		node curr = fila.top();
		fila.pop();
		int x = curr.x, y=curr.y;
		if(x == x2 and y == y2) ans=min(ans, curr.dist);
		if(curr > dist[curr.dir][x][y]) continue;
		// cout<<"CARA "<<x<<" "<<y<<" "<<curr.dir<<"   = "<<curr.dist<<"\n";

		for(int p = 0; p < 4; p++){
			int a = x + dx[p], b = y + dy[p];
			if(a <= 0 or b <= 0 or a > n or b > m or mat[a][b] == '@') continue;
			node novo = curr;
			novo.x=a, novo.y=b, novo.dir = p;
			if(p != curr.dir){
				novo.dist ++;
				novo.resta = k-1;
			}
			else{
				if(novo.resta <= 0){
					novo.dist ++;
					novo.resta = k-1;
				}
				else{
					novo.resta --;
				}
			}
			if(dist[p][a][b] > novo){
				fila.push(novo);
				// cout<<"FILHO "<<p<<" "<<a<<" "<<b<<" ==== "<<x<<" "<<y<<"\n";
				dist[p][a][b] = novo;
			}
		}
	}
	if(ans >= 200000000) cout<<"-1\n";
	else cout<<ans<<"\n";
}
/*
    CUIDADO COM MAXN, MOD, OVERFLOW 
    >Colocar (>DEFINE INT LONG LONG<) no inicio do template
    >mod = (1e9 + 7), por padrao (NAO ESQUECER DE ALTERAR)
    >NAO ESQUECER DEFINE INT LONG LONG
    > N = 1 ? 
*/
int summod(vector<int> w){int curr=0;for(int i=0;i<sz(w); i++){curr = (curr+w[i])%mod;if(curr<0)curr+=mod;}return curr;}
int prodmod(vector<int> w){int curr = 1;
for(int i = 0; i < sz(w); i++){if(w[i] >= mod) w[i] %= mod;curr = (curr * w[i]) % mod;if(curr < 0) curr += mod;}return curr;}

Measured memory_bytes: 107448