// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

const long long N = 1e6+5 , M = 998244353, OO = 0x3f3f3f3f;

typedef long long ll;

#define FIO ios_base::sync_with_stdio(0);cin.tie(0);

const double Pii = 3.14159265359;

int n, m, mxk, X1, Y1, X2, Y2;

bool grid[N];

int dis[N];

char ch;

int cr[] = {-1, 1, 0, 0};

int cc[] = {0, 0, -1, 1};



bool valid(int nr, int nc)

{

    return (nr >= 0 && nr < n && nc >= 0 && nc < m);

}



void BFS1(int X1, int Y1)

{

    memset(dis, OO, sizeof dis);

    dis[X1*m+Y1] = 0;

    queue<pair<int, int>> q;

    q.push({X1, Y1});

    while(!q.empty())

    {

        pair<int, int> pu = q.front();

        q.pop();

        for(int k=0; k<4; ++k)

        {

            int kused = 0;

            bool ok = 1;

            int nr = pu.first;

            int nc = pu.second;

            while(kused < mxk && ok)

            {

                nr += cr[k];

                nc += cc[k];

                if(valid(nr, nc) && grid[nr*m+nc] && dis[nr*m+nc] >= dis[pu.first*m+pu.second]+1)

                {

                    if(dis[nr*m+nc] > dis[pu.first*m+pu.second] + 1)

                    {

                        q.push({nr, nc});

                        dis[nr*m+nc] = dis[pu.first*m+pu.second] + 1;

                    }

                    kused++;

                }

                else ok = 0;

            }

        }

    }

}







int main()

{

    FIO

    cin >> n >> m >> mxk >> X1 >> Y1 >> X2 >> Y2;

    X1--; Y1--; X2--; Y2--;

    for(int i=0; i<n; ++i)

    {

        for(int j=0; j<m; ++j)

        {

            cin >> ch;

            if(ch == '.') grid[i*m+j] = 1;

            else grid[i*m+j] = 0;

        }

    }

    BFS1(X1, Y1);

    /*

    for(int i=0; i<n; ++i)

    {

        for(int j=0; j<m; ++j) cout << dis[i*m+j] << " ";

        cout << endl;

    }

    */



    if(dis[X2*m+Y2] == OO) cout << -1 << endl;

    else cout << dis[X2*m+Y2] << endl;

    return 0;

}


// Optimized solution to the same problem (faster):
#include<bits/stdc++.h>

#include<ext/pb_ds/assoc_container.hpp>

#include<ext/pb_ds/tree_policy.hpp>

using namespace std;

using namespace __gnu_pbds;

typedef tree<int,null_type,less<int>,rb_tree_tag,

tree_order_statistics_node_update> ordered_set;

#define debug(x) cout<<#x<<' '<<x<<endl

#define read(x)  freopen("input.txt","r",stdin);

#define iter(x)  x.begin(),x.end()

#define ll long long

#define ull unsigned ll

#define endl '\n'

#define inf INT_MAX

#define mod 1000000007

vector<vector<pair<int,int> > >parent;

int dx[]={1,-1,0,0};

int dy[]={0,0,1,-1};

pair<int,int>start,finish;

int h,w,k;

vector<vector<char> >grid;

bool valid(pair<int,int>p)

{

    return p.first<h and p.first>-1 and p.second<w and p.second>-1;

}

void bfs()

{



    queue<pair<int,int> >q;

    q.push(start);

    int dist[h][w];

    for(int i=0;i<h;i++)

        for(int j=0;j<w;j++)

            dist[i][j]=inf ;

    dist[start.first][start.second]=0;

    while(!q.empty())

    {

        pair<int,int> p=q.front();

        q.pop();



        for(int i=0;i<4;i++)

            for(int jj=1;jj<=k;jj++)

        {

            pair<int,int>j={p.first+dx[i]*jj,p.second+dy[i]*jj};



            if(!valid(j) or grid[j.first][j.second]!='.')

            {



                break;

            }

            if(1+dist[p.first][p.second]<dist[j.first][j.second])

            {

                dist[j.first][j.second]=1+dist[p.first][p.second];

                q.push(j);



            }

            else if(1+dist[p.first][p.second]>dist[j.first][j.second])

            {



                break;



            }



        }

    }





    if(dist[finish.first][finish.second]!=inf)

    {

        cout<<dist[finish.first][finish.second]<<endl;



    }

    else

        cout<<-1<<endl;



}

main()

{

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    cout.tie(NULL);

    cin>>h>>w>>k;

    parent.assign(h,vector<pair<int,int> >(w));

    grid.assign(h,vector<char >(w));

    cin>>start.first>>start.second>>finish.first>>finish.second;

     start.first--,start.second--,finish.first--,finish.second--;

    for(auto &c:grid)

        for(auto &x:c)

            cin>>x;



    bfs();





}


// Fastest known solution for this problem: