#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) { os << "[ "; 
	for(auto v:V)os << v << " "; return os << "]";
}
template<class T> ostream& operator<<(ostream &os, set<T> S){ os << "{ "; 
	for(auto s:S) os<<s<<" ";  return os<<"}"; 
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
	return os<<"("<<P.first<<","<< P.second << ")";
}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) {
	os<<"{ ";for(auto m:M)os<<"("<<m.F<<":"<<m.S<<")";
	return os<<"}";
}
#define cerr cout
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
#define ll long long
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define I insert 
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define For(i,n) for(int i=0;i<(int)n;++i)
#define Rev(i,n) for(int i=(int)n-1;i>=0;--i)
#define Rep(i,n) for(int i=1;i<=(int)n;++i)
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,pair<char, int> > ppi;
typedef vector<pii> vpii;

#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

const int N = 1e6 + 100;
const int INF = 1e9;

pii dis[4][N];
int h , w , k;
char dir[] = {'R' , 'D' , 'U' , 'L'};

int conv(int i , int j){
	return w*i + j;
}
pii dconv(int i){
	return mp(i/w , i%w);
}
char grid[N];
int dx[] = {0 , 1 , -1, 0};
int dy[] = {1 , 0 , 0 , -1};

int main(){
	fio; cout<<fixed<<setprecision(25);	
	cin >> h >> w >> k;
	for(int i = 0 ;i < h*w ; ++i){
		for(int z = 0 ; z < 4 ; ++z)
			dis[z][i] = mp(INF , INF);
	}
	int x1 , y1 , x2 , y2;
	cin >> x1 >> y1 >> x2 >> y2;
	--x1 , --y1 , --x2, --y2;
	int idx = 0;

	for(int i = 0;i < h ; ++i){
		for(int j = 0;j < w ; ++j){
			cin >> grid[idx++];
		}
	}

	priority_queue<ppi, vector<ppi> , greater<ppi> > Q;
	for(int z = 0 ; z < 4 ; ++z){
		dis[z][conv(x1 , y1)] = mp(1 , -k);
		Q.push(mp(dis[z][conv(x1 , y1)] , mp(dir[z] , conv(x1 , y1)) ));
	}

	while(Q.size()){
		auto it = Q.top();
		Q.pop();
		// trace(it);
		pii p = dconv(it.S.S);
		// trace(it.F ,it.S.F ,  p);
		for(int z = 0; z < 4 ; ++z){
			int x = dx[z]+p.F , y = dy[z] + p.S;
			if(x < 0 || x >= h || y < 0 || y >= w) continue;
			// trace(x , y , grid[conv(x , y)]);
			if(grid[conv(x , y)] == '@'){
				continue;
			}
			pii d = it.F;
			if(dir[z] != it.S.F || d.S == 0){
				d = mp(d.F+1 , -k+1);				
			}
			else{
				++d.S;
			}
			if(dis[z][conv(x , y)] > d){
				dis[z][conv(x , y)] = d;
				Q.push(mp(dis[z][conv(x , y)] , mp(dir[z] , conv(x , y))));
			}
		}
	}
	int ans = INF;
	for(int z = 0 ; z < 4 ; ++z){
		ans = min(ans , dis[z][conv(x2 , y2)].F);
	}
	if(ans == INF){
		cout << -1 << endl;
	}
	else{
		cout << ans << endl;
	}






	return 0;
}


Measured memory_bytes: 39624