#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
#define PIL pair<int,LL>
#define PLI pair<LL,int>
#define PIII pair<int,PII>
#define PIIII pair<int,PIII>
#define PLL pair<LL,LL>
#define PLII pair<LL,PII>
#define VI vector<int>
#define VVI vector<VI>
#define VL vector<LL>
#define VVL vector<VL>
#define VPII vector<PII>
#define FF first
#define SS second
#define MP make_pair
#define PB push_back
#define all(x) x.begin(),x.end()
#define watch(x) cout<<(#x)<<" = "<<(x)<<'\n'
#define mset(a,v) memset(a,v,sizeof(a))
#define setp(x) cout<<fixed<<setprecision(x)
#define EPS 0.00000000001
#define PI acos(-1)
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
using namespace std;

const int MOD = 1e9 + 7;
const LL MX = 2e5 + 100;
const LL INF = 1e9 + 100;

void print_a(VI v)
{
    if(v.size()) cout<<v[0];
    loop(i,1,v.size()) cout<<' '<<v[i];
    cout<<'\n';
}

VVI init_vvi(int n, int m, int val)
{
    return VVI(n,VI(m,val));
}

VVL init_vvl(int n, int m, LL val)
{
    return VVL(n,VL(m,val));
}

int h,w,k;
vector<string> g;
VVI l[4], c[4];

void bfs(int ux, int uy)
{
    priority_queue<PIIII, vector<PIIII>, greater<PIIII> > q;
    l[0][ux][uy] = 0;
    c[0][ux][uy] = 0;
    q.push({0,MP(0,MP(ux,uy))});

    int f, vx,vy,d;
    int xc[4] = {0,0,-1,1};
    int yc[4] = {-1,1,0,0};
    while(!q.empty())
    {
        d = q.top().FF;
        f = q.top().SS.FF;
        ux = q.top().SS.SS.FF;
        uy = q.top().SS.SS.SS;
        //cout<<ux<<' '<<uy<<' '<<f<<' '<<d<<'\n';
        q.pop();
        if(d != l[f][ux][uy]) continue;
        loop(i,0,4)
        {
            vx = ux + xc[i];
            vy = uy + yc[i];
            if(vx >= 0 && vy >= 0 && vx < h && vy < w && g[vx][vy] == '.')
            {
                if(i != f)
                {
                    if(l[i][vx][vy] == -1 || l[f][ux][uy] + 1 < l[i][vx][vy])
                    {
                        l[i][vx][vy] = l[f][ux][uy] + 1;
                        c[i][vx][vy] = 1;
                        q.push({l[i][vx][vy],MP(i,MP(vx,vy))});
                    }
                }
                else
                {
                    if(c[f][ux][uy] == k)
                    {
                        if(l[i][vx][vy] == -1 || l[f][ux][uy] + 1 < l[i][vx][vy])
                        {
                            l[i][vx][vy] = l[f][ux][uy] + 1;
                            c[i][vx][vy] = 1;
                            q.push({l[i][vx][vy],MP(i,MP(vx,vy))});
                        }
                    }
                    else
                    {
                        if(l[i][vx][vy] == -1 || max(1,l[f][ux][uy]) < l[i][vx][vy])
                        {
                            l[i][vx][vy] = max(1,l[f][ux][uy]);
                            c[i][vx][vy] = c[f][ux][uy] + 1;
                            q.push({l[i][vx][vy],MP(i,MP(vx,vy))});
                        }
                    }
                }
            }
        }
    }
}

int main()
{
    //ofstream out("output.txt");
    //ifstream in("input.txt");
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    int x1,y1,x2,y2;
    cin>>h>>w>>k>>x1>>y1>>x2>>y2;
    g.resize(h);
    loop(i,0,4)
    {
        l[i].resize(h,VI(w,-1));
        c[i].resize(h,VI(w,-1));
    }
    loop(i,0,h)
    {
        cin>>g[i];
    }

    bfs(x1-1,y1-1);
    int ans = -1;
    loop(i,0,4)
    {
        if(l[i][x2-1][y2-1] != -1)
        {
            if(ans == -1 || l[i][x2-1][y2-1] < ans) ans = l[i][x2-1][y2-1];
        }
    }

    cout<<ans<<'\n';

    /*
    int t,n;
    cin>>t;
    while(t--)
    {
        cin>>n;
        int a[n];
        loop(i,0,n)
        {
            cin>>a[i];
        }
    }
    */

    /*
    int n;
    cin>>n;
    int a[n];
    loop(i,0,n)
    {
        cin>>a[i];
    }
    */

    /*
    cout<<ans<<'\n';

    if(f) cout<<"YES\n";
    else cout<<"NO\n";

    if(f) cout<<"Yes\n";
    else cout<<"No\n";
    */

    return 0;
}


Measured memory_bytes: 39896