#include <bits/stdc++.h>
using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//typedef vector<vector<ll>> Graph;

const ll mod = 1e9 + 7;
//const ll mod = 998244353;

#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define spa << " " <<
#define fi first
#define se second

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

template<typename T> void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cerr<<v[i][0];for(ll j=1;j<w;j++)cerr spa v[i][j];cerr<<endl;}};
template<typename T> void debug(vector<T>&v,ll n){if(n!=0)cerr<<v[0];
for(ll i=1;i<n;i++)cerr spa v[i];
cerr<<endl;};

string num2bit(ll num, ll len){
    string bit = "";
    REP(i, len){
    bit += char('0'+(num>>i & 1));
    }
    return bit;
}

struct Pi{
    ll d, x, y, dir;
    bool operator>(const Pi &right) const{
        if(d != right.d) return d>right.d;
        else if(x != right.x) return x>right.x;
        else if(y != right.y) return y>right.y;
        else return dir>right.dir;
    }
    Pi(ll d, ll x, ll y, ll dir): d(d), x(x), y(y), dir(dir) {};
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll H, W, K;
    cin >> H >> W >> K;
    ll x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    x1--, y1--, x2--, y2--;

    auto modCeil = [&](ll x){
        return (x+K-1)/K * K;
    };

    vector<string> S(H);
    REP(i, H) cin >> S[i];

    const ll INF  = (1ll<<60);
    vector<vector<vector<ll>>> dist(H, vector<vector<ll>>(W, vector<ll>(4, INF)));
    priority_queue<Pi, vector<Pi>, greater<Pi>> pq;
    auto push = [&](ll x, ll y, ll dir, ll d){
        if(dist[x][y][dir] <= d) return;
        dist[x][y][dir]  = d;
        pq.emplace(d, x, y, dir);
    };

    REP(i, 4){
        push(x1, y1, i, 0);
    }
    vector<ll> dx = {-1, 0, 1, 0};
    vector<ll> dy = {0, -1, 0, 1};
    
    while(!pq.empty()){
        auto p = pq.top();pq.pop();
        if(dist[p.x][p.y][p.dir] < p.d) continue;
        REP(ndir, 4) push(p.x, p.y, ndir, modCeil(p.d));
        ll nx = p.x + dx[p.dir];
        ll ny = p.y + dy[p.dir];
        if(nx<0 or nx>H-1 or ny<0 or ny>W-1) continue;
        if(S[nx][ny] == '@') continue;
        push(nx, ny, p.dir, p.d+1);
    }

    ll res = INF;
    REP(dir, 4) chmin(res, dist[x2][y2][dir]);

    /*
    REP(i, 4){
        REP(j, H){
            REP(k, W){
                cout << (dist[j][k][i] == INF ? -1 : dist[j][k][i]) << " "; 
            }
            cout << endl;
        }
        cout << endl;
    }
    */

    if(res == INF){
        cout << -1 << endl;
    }else{
        cout << modCeil(res)/K << endl;
    }

    return 0;
}

Measured memory_bytes: 144980