//2020年4月17日現在

#include<stdio.h>
#include<cmath>
#include<math.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<complex>
#include<queue>
#include<set>
#include<utility>
#include<iomanip>
#include<limits>
#include<thread>
#include<map>
#include<stack>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<tuple>
#include <cstdio>

using namespace std;

template <class... A>
void prints() { cout << "\n"; }
template <class... A>
void prints_rest() { cout << "\n"; }
template <class T, class... A>
void prints_rest(const T &first, const A &... rest) { cout << " " << first; prints_rest(rest...); }
template <class T, class... A>
void prints(const T &first, const A &... rest) { cout << first; prints_rest(rest...); }
template <class T, class... A>
void printd(const T &first, const A &... rest) { cout << fixed << setprecision(15) << first; prints_rest(rest...); }


namespace {
    // printElems(&a[0], &a[n]);　みたいな感じで使う。
    void printElems(const int* begin, const int* end)
    {
        for (const int* p = begin; p != end; ++p) {
            std::cout << *p << ' ';
        }
        std::cout << std::endl;
    }
}

#define rep(i,n) for(int i=0; i<n; i++)
#define rep1(i,n) for(int i=1; i<n+1; i++)
#define repr(i,n) for(int i=n-1; i>=0; i--)
#define repr1(i,n) for(int i=n; i>0; i--)
#define FOR(i,j,n) for(int i=j; i < n; i++)
#define souatari(i,j,n) rep1(i,n-1)rep(j,i)
#define souatari1(i,j,n) for(int i=2; i<n+1; i++)rep1(j,i-1)
#define mp make_pair
#define F first
#define S second
#define elif else if

typedef long long ll;
typedef vector<int>  vi;
typedef vector<vi>  vvi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef array<int,3> arr3;
typedef long double D;


const ll llinf =  numeric_limits<ll>::max();
const ll _llinf = numeric_limits<ll>::lowest();
const int inf = numeric_limits<int>::max();
const int _inf = numeric_limits<int>::lowest();
const double dinf = numeric_limits<double>::infinity();
const ll MOD = 1000000007;
const ll BIG = 1LL<<60;







int main(){
    int h,w,k;
    cin >> h >> w >> k;
    int xs,ys,xg,yg;
    cin >> xs >> ys >> xg >> yg;
    int maze[h+5][w+5] = {};
    rep1(i,h){
        string tmp;
        cin >> tmp;
        rep1(j,w){
            if(tmp[j-1] == '@') maze[i][j] = 1;
        }
    }
    rep(i,h+2) {maze[i][0] = 1; maze[i][w+1] = 1;}
    rep(i,w+2) {maze[0][i] = 1; maze[h+1][i] = 1;}


    //rep(i,h+3)printElems(&maze[i][0],&maze[i][w+3]);

    int nx[4] = {1,0,-1,0};
    int ny[4] = {0,1,0,-1};

    queue<arr3> q;
    q.push({xs,ys,1});
    maze[xs][ys] = 1;

    while(!q.empty()){
        arr3 tmp = q.front();
        q.pop();
        for(int t = 0; t < 4; t++){
            rep1(i,k){
                if(maze[tmp[0]+nx[t]*i][tmp[1]+ny[t]*i]!=0 && maze[tmp[0]+nx[t]*i][tmp[1]+ny[t]*i]<=tmp[2]) break;
                if(maze[tmp[0]+nx[t]*i][tmp[1]+ny[t]*i]!=0) continue;
                maze[tmp[0]+nx[t]*i][tmp[1]+ny[t]*i] = tmp[2]+1;
                q.push({tmp[0]+nx[t]*i,tmp[1]+ny[t]*i,tmp[2]+1});
            }
        }
    }
    //rep(i,h+3)printElems(&maze[i][0],&maze[i][w+3]);

    prints(maze[xg][yg]-1);




    return 0;
}




Measured memory_bytes: 28676