using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol = new Sol();
		mySol.Solve();
	}
}

class Sol{
	bool InRange(int t, int l, int r){
		return l <= t && t < r;
	}
	public void Solve(){

		int HW = H * W;
		long Inf = (long) 1e18;
		int[] dy = new int[]{0,-1,0,1};
		int[] dx = new int[]{1,0,-1,0};
		
		int B2 = HW * 2;
		
		Func<int, int, int, int> enc = (_t, _y, _x) => _t * B2 + _y * W + _x;
		Func<int, int, int> enc2 = (_y, _x) => _y * W + _x;
		
		long[][] min = new long[4][];
		for(int i=0;i<4;i++){
			min[i] = new long[HW];
			for(int j=0;j<HW;j++){
				min[i][j] = Inf;
			}
		}
		
		var SH = new SkewHeap<Pair>();
		for(int i=0;i<4;i++){
			int thw = enc(i, X1, Y1);
			SH.Push(new Pair(thw, 0));
			min[i][thw % B2] = 0;
		}
		
		bool[][] used = new bool[4][];
		for(int i=0;i<4;i++) used[i] = new bool[HW];
		
		while(SH.Count > 0){
			var p = SH.Top; SH.Pop();
			int thw = p.Pos;
			int t0 = thw / B2;
			int y = thw % B2 / W;
			int x = thw % W;
			long cost = p.Cost;
			if(used[t0][thw % B2]) continue;
			used[t0][thw % B2] = true;
			
			
			for(int t=0;t<4;t++){
				int ny = y + dy[t];
				int nx = x + dx[t];
				if(!InRange(ny, 0, H) || !InRange(nx, 0, W)) continue;
				if(S[ny][nx] == '@') continue;
				if(t == t0){
					long nc = cost + 1;
					if(min[t][enc2(ny, nx)] > nc){
						min[t][enc2(ny, nx)] = nc;
						SH.Push(new Pair(enc(t, ny, nx), nc));
					}
				} else {
					long nc = (cost + (K - 1)) / K * K + 1;
					if(min[t][enc2(ny, nx)] > nc){
						min[t][enc2(ny, nx)] = nc;
						SH.Push(new Pair(enc(t, ny, nx), nc));
					}
				}
			}
		}
		
		/*
		for(int i=0;i<4;i++){
			Console.WriteLine("dir:{0}", i);
			for(int j=0;j<H;j++){
				Console.WriteLine(String.Join(" ", min[i].Skip(j * W).Take(W))); 
			}
		}
		*/
		
		long minc = Inf;
		for(int i=0;i<4;i++){
			if(minc > min[i][enc2(X2, Y2)]){
				minc = min[i][enc2(X2, Y2)];
			}
		}
		
		if(minc == Inf){
			Console.WriteLine(-1);
		} else {
			Console.WriteLine((minc + K - 1) / K);
		}
		
		
	}
	int H,W,K;
	int X1,Y1,X2,Y2;
	String[] S;
	public Sol(){
		var d = ria();
		H = d[0]; W = d[1]; K = d[2];
		d = ria();
		X1 = d[0] - 1; Y1 = d[1] - 1; X2 = d[2] - 1; Y2 = d[3] - 1;
		S = new String[H];
		for(int i=0;i<H;i++) S[i] = rs();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


class Pair : IComparable<Pair> {
	public int Pos;
	public long Cost;
	public Pair(int p, long c) {
		Pos = p; Cost = c;
	}
	public int CompareTo(Pair t) {
		//return this.Cost > t.Cost ? -1 : this.Cost < t.Cost ? 1 : 0;
		return this.Cost > t.Cost ? 1 : this.Cost < t.Cost ? -1 : 0;
	}
}


class SkewHeap<T> where T:IComparable<T>{
	public int Count{
		get{return cnt;}
		private set{cnt=value;}
	}
	
	public SkewHeap(){
		root=null;
		this.Count=0;
	}
	
	public void Push(T v){
		NodeSH<T> p=new NodeSH<T>(v);
		root=NodeSH<T>.Meld(root,p);
		this.Count++;
	}
	
	public void Pop(){
		if(root==null)return;
		root=NodeSH<T>.Meld(root.L,root.R);
		this.Count--;
	}
	
	public T Top{
		get{return root.Val;}
	}
	
	int cnt;
	NodeSH<T> root;
	
	class NodeSH<S> where S : IComparable<S> {
		public NodeSH<S> L, R;
		public S Val;

		public NodeSH(S v){
			Val = v;
			L = null; R = null;
		}
		public static NodeSH<S> Meld(NodeSH<S> a, NodeSH<S> b){
			if(a == null)return b;
			if (b == null) return a;
			if (a.Val.CompareTo(b.Val) > 0) swap(ref a, ref b);
			a.R = Meld(a.R, b);
			swap(ref a.L, ref a.R);
			return a;
		}

		static void swap<U>(ref U x, ref U y) {
			U t = x; x = y; y = t;
		}
	}
}


Measured memory_bytes: 118232