unittest
{
	assert( [ "3 5 2", "3 2 3 4", ".....", ".@..@", "..@.." ].solve == 5 );
	assert( [ "1 6 4", "1 1 1 6", "......" ].solve == 2 );
	assert( [ "3 3 1", "2 1 2 3", ".@.", ".@.", ".@." ].solve == -1 );
	
	assert( [ "10 10 10", "5 5 10 10", "..........", "..........", "..........", "..........", "..........", "..........", "..........", "..........", "..........", ".........." ].solve == 2 );		// 追加ケース
}



import std.conv;
import std.format;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto h = 0L;
	auto w = 0L;
	auto k = 0L;
	input.front.formattedRead!"%s %s %s"( h, w, k );
	input.popFront;
	auto sy = 0L;
	auto sx = 0L;
	auto gy = 0L;
	auto gx = 0L;
	input.front.formattedRead!"%s %s %s %s"( sy, sx, gy, gx );
	auto css = new dchar[][]( h, w );
	foreach( ref cs; css )
	{
		input.popFront;
		cs = input.front.to!( dchar[] );
	}
	sy--;
	sx--;
	gy--;
	gx--;
	
	auto dss = dijkstraGridEx( css, k, sy, sx );
	return ( dss[ gy ][ gx ] == long.max ) ? -1 : ( dss[ gy ][ gx ] + k - 1 ) / k;
}

// 正のグリッドマップの始点指定最短経路探索（ダイクストラ法）
auto dijkstraGridEx( T, T W = '@' )( T[][] css, long k, long sy, long sx )
{
	import std.container.binaryheap;
	
	auto dss = new long[][]( css.length, css[ 0 ].length );
	foreach( ref ds; dss ) ds[] = long.max;
	dss[ sy ][ sx ] = 0;
	auto us = new bool[][][]( css.length, css[ 0 ].length, 4 );
	
	auto queue = heapify!( ( a, b ) => b[ 3 ] < a[ 3 ] )( [ tuple( sy, sx, 0L, 0L ), tuple( sy, sx, 1L, 0L ), tuple( sy, sx, 2L, 0L ), tuple( sy, sx, 3L, 0L ) ] );
	while( !queue.empty )
	{
		auto fy = queue.front[ 0 ];
		auto fx = queue.front[ 1 ];
		auto ff = queue.front[ 2 ];
		auto fd = queue.front[ 3 ];
		queue.popFront();
		
		if( us[ fy ][ fx ][ ff ] ) continue;
		us[ fy ][ fx ][ ff ] = true;
		
		foreach( i, p; [ [ -1, 0 ], [ 1, 0 ], [ 0, -1 ], [ 0, 1 ] ] )
		{
			auto ty = fy + p[ 0 ];
			auto tx = fx + p[ 1 ];
			
			if( ty < 0 || css.length <= ty || tx < 0 || css[ ty ].length <= tx ) continue;		// マップ外
			if( css[ ty ][ tx ] == W ) continue;		// 壁
			
			auto td = fd + 1;
			if( ff != i ) td = ( fd + k - 1 ) / k * k + 1;
			
			if( dss[ ty ][ tx ] < td ) continue;
			
			dss[ ty ][ tx ] = td;
			queue.insert( tuple( ty, tx, i.signed, td ) );
		}
	}
	return dss;
}
