#include"bits/stdc++.h"

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
typedef priority_queue<VL> PQ_DESC_VL;
typedef priority_queue<VL, vector<VL>, greater<VL>> PQ_ASC_VL;
typedef priority_queue<PLL> PQ_DESC_PLL;
typedef priority_queue<PLL, vector<PLL>, greater<PLL>> PQ_ASC_PLL;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF*(LL)INF;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;



void Main()
{
    int h,w,k;cin>>h>>w>>k;
    int x1,y1,x2,y2;cin>>x1>>y1>>x2>>y2;
    x1--;y1--;x2--;y2--;

    const int tate = 0;
    const int yoko = 1;

    VS s(h);
    REP(i,h){
        cin>>s[i];
    }

    vector<VVL> d(h);
    vector<vector<vector<bool>>> visited(h);
    REP(i,h){
        d[i].resize(w);
        visited[i].resize(w);
        REP(j,w){
            d[i][j].resize(2,INF_LL);
            visited[i][j].resize(2,false);
        }
    }

    PQ_ASC_VL pq;
    pq.push({0,tate,x1,y1});
    pq.push({0,yoko,x1,y1});
    d[x1][y1][tate] = 0;
    d[x1][y1][yoko] = 0;

    while(!pq.empty()){
        LL cost = pq.top()[0];
        LL muki = pq.top()[1];
        LL x = pq.top()[2];
        LL y = pq.top()[3];
        pq.pop();

        if(x==x2 && y==y2){
            cout<<cost<<endl;
            return;
        }

        if(visited[x][y][muki]){
            continue;
        }
        visited[x][y][muki] = true;

        LL ncost = cost+1;

        if(true){
            //up
            FOR(i,1,k+1){
                int nx = x-i;
                int ny = y;
                if(nx<0){
                    break;
                }
                if(s[nx][ny] == '@'){
                    break;
                }
                if(d[nx][ny][tate] <= ncost){
                    break;
                }
                if(d[nx][ny][yoko] <= cost){
                    break;
                }
                d[nx][ny][tate] = ncost;
                pq.push({ncost,tate,nx,ny});
            }
            //down
            FOR(i,1,k+1){
                int nx = x+i;
                int ny = y;
                if(nx>=h){
                    break;
                }
                if(s[nx][ny] == '@'){
                    break;
                }
                if(d[nx][ny][tate] <= ncost){
                    break;
                }
                if(d[nx][ny][yoko] <= cost){
                    break;
                }
                d[nx][ny][tate] = ncost;
                pq.push({ncost,tate,nx,ny});
            }
            //left
            FOR(i,1,k+1){
                int nx = x;
                int ny = y-i;
                if(ny<0){
                    break;
                }
                if(s[nx][ny] == '@'){
                    break;
                }
                if(d[nx][ny][tate] <= cost){
                    break;
                }
                if(d[nx][ny][yoko] <= ncost){
                    break;
                }
                d[nx][ny][yoko] = ncost;
                pq.push({ncost,yoko,nx,ny});
            }
            //right
            FOR(i,1,k+1){
                int nx = x;
                int ny = y+i;
                if(ny>=w){
                    break;
                }
                if(s[nx][ny] == '@'){
                    break;
                }
                if(d[nx][ny][tate] <= cost){
                    break;
                }
                if(d[nx][ny][yoko] <= ncost){
                    break;
                }
                d[nx][ny][yoko] = ncost;
                pq.push({ncost,yoko,nx,ny});
            }
        }


    }
    cout<<"-1"<<endl;


	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 138156