#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define sz(v) (int) v.size()
#define pr(v) For(i, 0, sz(v)) {cout<<v[i]<<" ";} cout<<endl;
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(ll i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define ld long double
#define int long long
#define double long double
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
typedef vector<int> vi;
#define pi 3.141592653589793238
const int MOD = 1e9+7;
const int INF = 1LL<<60;


const int N = 2e5+5;

// it's swapnil07 ;)
 
#ifdef SWAPNIL07
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define endl '\n'
#define trace(...)
#define end_routine()
#endif

int h, w, k;


void solve(){
    cin>>h>>w>>k;
    vector<set<int>> row(h), col(w), rrow(h), rcol(w);
    vector<set<int>> hrow(h), hcol(w), hrrow(h), hrcol(w);
    vector<vector<int> > ans(h, vector<int>(w, INF)); 
    int x1, y1, x2, y2; cin>>x1>>y1>>x2>>y2;
    x1--; x2--; y1--; y2--;

    For(i, 0, h){
        For(j, 0, w){
            char c; cin>>c;
            if(c=='.'){
                row[i].insert(j);
                col[j].insert(i);
                rrow[i].insert(-j);
                rcol[j].insert(-i);
            }
            else{
                hrow[i].insert(j);
                hcol[j].insert(i);
                hrrow[i].insert(-j);
                hrcol[j].insert(-i);
            }
        }
    }

    queue<pii> q;
    q.push({x1, y1});
    ans[x1][y1]=0;
    row[x1].erase(y1);
    col[y1].erase(x1);
    rrow[x1].erase(-y1);
    rcol[y1].erase(-x1);
    while(!q.empty()){
        pii p = q.front();
        q.pop();
        int x = p.F;
        int y = p.S;
        trace(x, y);
        int nx = ans[x][y]+1;
        while(row[x].upper_bound(y)!=row[x].end()){
            int yy = *row[x].upper_bound(y);
            if(hrow[x].upper_bound(y)!=hrow[x].upper_bound(yy))
                break;
            if(abs(yy-y)<=k){
                ans[x][yy]=nx;
                row[x].erase(yy);
                col[yy].erase(x);
                rrow[x].erase(-yy);
                rcol[yy].erase(-x);
                q.push({x, yy});
            }
            else{
                break;
            }
        }
        while(col[y].upper_bound(x)!=col[y].end()){
            int xx = *col[y].upper_bound(x);
            if(hcol[y].upper_bound(x)!=hcol[y].upper_bound(xx)){
                break;
            }
            if(abs(xx-x)<=k){
                ans[xx][y]=nx;
                col[y].erase(xx);
                rcol[y].erase(-xx);
                row[xx].erase(y);
                rrow[xx].erase(-y);
                q.push({xx, y});
            }
            else{
                break;
            }
        }
        // back direction
        while(rrow[x].upper_bound(-y)!=rrow[x].end()){
            int yy = *rrow[x].upper_bound(-y);
            yy *= -1;
            if(hrrow[x].upper_bound(-y)!=hrrow[x].upper_bound(-yy))
                break;
            if(abs(yy-y)<=k){
                ans[x][yy]=nx;
                row[x].erase(yy);
                col[yy].erase(x);
                rrow[x].erase(-yy);
                rcol[yy].erase(-x);
                q.push({x, yy});
            }
            else{
                break;
            }
        }
        while(rcol[y].upper_bound(-x)!=rcol[y].end()){
            int xx = *rcol[y].upper_bound(-x);
            xx *= -1;
            if(hrcol[y].upper_bound(-x)!=hrcol[y].upper_bound(-xx)){
                break;
            }
            if(abs(xx-x)<=k){
                ans[xx][y]=nx;
                col[y].erase(xx);
                rcol[y].erase(-xx);
                row[xx].erase(y);
                rrow[xx].erase(-y);
                q.push({xx, y});
            }
            else{
                break;
            }
        }
    }
    if(ans[x2][y2]!=INF){
        cout<<ans[x2][y2];
    }
    else{
        cout<<-1;
    }
}


signed main()
{
    fast
    #ifdef SWAPNIL07
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    int t=1; 
    // cin>>t;
    while(t--){
        solve();
        cout<<"\n";
    }
    return 0;
}



Measured memory_bytes: 386096