#include <bits/stdc++.h>

// headers {{{
using namespace std;
// using namespace rel_ops;
 
const double pi=acos(-1.0);
const double eps=1e-11;
const int INF=0x7FFFFFFF;
template<class T> inline bool checkmin(T &a,T b){return b<a?a=b,1:0;}
template<class T> inline bool checkmax(T &a,T b){return b>a?a=b,1:0;}
template<class T> inline T sqr(T x){return x*x;}
template<class T> inline bool bit(T a, int b) {return (a>>b)&1;}
inline int popcount(int n) { return __builtin_popcount(n); }
inline int popcount(long long n) { return __builtin_popcountll(n); }
typedef long long int64;
typedef unsigned long long uint64;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
#define MP(A,B) make_pair(A,B)
#define PB(X) push_back(X)
#define eb(args...) emplace_back(args)
#define rep(i,n) for(int i=0; i<(int)n; i++)
#define ff first
#define ss second
#define sz(g) int(g.size())
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
#ifdef LOCAL
#define dout cerr 
void out() { dout << endl; }
template<typename A, typename... B> void out(A a, B... b) { dout << ' ' << a; out(b...); }
#define dbg(args...) dout << __LINE__ << ":(" << #args << ") -> ", out(args)
template<class T>void show(T a, int n){for(int i=0; i<n; ++i) cout<<a[i]<<' '; cout<<endl;}
template<class T>void show(T a, int r, int l){for(int i=0; i<r; ++i)show(a[i],l);cout<<endl;}
constexpr bool local = true;
#else
#define dbg(...)
#define dout if(true);else cerr
#define out(...)
#define show(...)
constexpr bool local = false;
#endif
// }}}
const int N = 1e6+10;
vector<int> vis[N];
string s[N];
int H, W, K;
int x1, yy1, x2, y2;
int dx[] = {0, 0, 1, -1};
int dy[] = {-1, 1, 0, 0};
inline bool valid(int x, int y) {
    return x >= 0 && x < H && y >=0 && y < W;
}
int bfs() {
    vector<PII> cur, nxt;
    cur.PB(MP(x1, yy1));
    vis[x1][yy1] = 0;
    if (x1 == x2 && yy1 == y2) return 0;
    int r = 0;
    while (true) {
        r++;
        nxt.clear();
        for (auto t : cur) {
            int x = t.ff, y = t.ss;
            rep(d, 4) {
                int tx = x, ty = y;
                rep(j, K) {
                    tx += dx[d], ty += dy[d];
                    if (!valid(tx, ty)) break;
                    if (vis[tx][ty] < r) break;
                    if (s[tx][ty] == '@') break;
                    if (vis[tx][ty] > r) {
                        vis[tx][ty] = r;
                        nxt.eb(tx, ty);
                    }
                    if (tx == x2 && ty == y2) return r;
                }
            }
        }
        if (nxt.empty()) return -1;
        swap(nxt, cur);
    }
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL); 
    while (cin >> H >> W >> K) {
        cin >> x1 >> yy1 >> x2 >> y2;
        x1--, yy1--, x2--, y2--;
        rep(i, H) {
          vis[i].resize(W);
          rep(j, W) vis[i][j] = 1e9;
        }
        rep(i, H) {
            cin >> s[i];
        }
        int ans = bfs();
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 64272