//Utkarsh.25dec
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// ordered_set s ; s.order_of_key(val)  no. of elements strictly less than val
// s.find_by_order(i)  itertor to ith element (0 indexed)
typedef vector<vector<ll>> matrix;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=500023;
bool vis[N];
vector <int> adj[N];
void solve()
{
    ll n,m,k;
    cin>>n>>m>>k;
    ll x1,y1,x2,y2;
    cin>>x1>>y1>>x2>>y2;
    char board[n+1][m+1];
    set <pair<ll,ll>> remrow;
    set <pair<ll,ll>> remcol;
    int dist[n+1][m+1];
    int row[n+1][m+1];
    int col[n+1][m+1];
    for(int i=1;i<=n;i++)
    {
        string s;
        cin>>s;
        for(int j=1;j<=m;j++)
        {
            remrow.insert(mp(i,j));
            remcol.insert(mp(j,i));
            dist[i][j]=1e9;
            board[i][j]=s[j-1];
        }
    }
    for(int i=0;i<=n;i++)
        row[i][0]=0;
    for(int j=0;j<=m;j++)
        col[0][j]=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            row[i][j]=row[i][j-1];
            if(board[i][j]=='@')
                row[i][j]++;
        }
    }
    for(int j=1;j<=m;j++)
    {
        for(int i=1;i<=n;i++)
        {
            col[i][j]=col[i-1][j];
            if(board[i][j]=='@')
                col[i][j]++;
        }
    }
    dist[x1][y1]=0;
    remrow.erase(mp(x1,y1));
    remcol.erase(mp(y1,x1));
    queue <pair<int,int>> q;
    q.push(mp(x1,y1));
    while(!q.empty())
    {
        auto curr=q.front();
        q.pop();
        int x=curr.first;
        int y=curr.second;
        auto it=remrow.lower_bound(mp(x,y));
        vector <pair<ll,ll>> removethem;
        while(it!=remrow.end())
        {
            if((*it).first!=x)
                break;
            int nowy=(*it).second;
            if((nowy-y)>k)
                break;
            ll blocks=row[x][nowy]-row[x][y-1];
            if(blocks>0)
                break;
            removethem.pb(mp(x,nowy));
            q.push(mp(x,nowy));
            dist[x][nowy]=dist[x][y]+1;
            it++;
        }
        for(auto it:removethem)
        {
            remrow.erase(mp(it.first,it.second));
            remcol.erase(mp(it.second,it.first));
        }
        removethem.clear();
        auto it2=remcol.lower_bound(mp(y,x));
        while(it2!=remcol.end())
        {
            if((*it2).first!=y)
                break;
            int nowx=(*it2).second;
            if((nowx-x)>k)
                break;
            ll blocks=col[nowx][y]-col[x-1][y];
            if(blocks>0)
                break;
            removethem.pb(mp(nowx,y));
            q.push(mp(nowx,y));
            dist[nowx][y]=dist[x][y]+1;
            it2++;
        }
        for(auto it:removethem)
        {
            remrow.erase(mp(it.first,it.second));
            remcol.erase(mp(it.second,it.first));
        }
        removethem.clear();
        {
            auto it=remrow.lower_bound(mp(x,y));
            if(remrow.size()!=0 && it!=remrow.begin())
            {
                while(it!=remrow.begin())
                {
                    auto it2=it;
                    it2--;
                    if((*it2).first!=x)
                        break;
                    int nowy=(*it2).second;
                    if((y-nowy)>k)
                        break;
                    ll blocks=row[x][y]-row[x][nowy-1];
                    if(blocks>0)
                        break;
                    removethem.pb(mp(x,nowy));
                    q.push(mp(x,nowy));
                    dist[x][nowy]=dist[x][y]+1;
                    it--;
                }
            }
            for(auto it:removethem)
            {
                remrow.erase(mp(it.first,it.second));
                remcol.erase(mp(it.second,it.first));   
            }
            removethem.clear();
        }
        {
            auto it=remcol.lower_bound(mp(y,x));
            if(remcol.size()!=0 && it!=remcol.begin())
            {
                while(it!=remcol.begin())
                {
                    auto it2=it;
                    it2--;
                    if((*it2).first!=y)
                        break;
                    int nowx=(*it2).second;
                    if((x-nowx)>k)
                        break;
                    ll blocks=col[x][y]-col[nowx-1][y];
                    if(blocks>0)
                        break;
                    removethem.pb(mp(nowx,y));
                    q.push(mp(nowx,y));
                    dist[nowx][y]=dist[x][y]+1;
                    it--;
                }
            }
            for(auto it:removethem)
            {
                remrow.erase(mp(it.first,it.second));
                remcol.erase(mp(it.second,it.first));
            }
            removethem.clear();
        }
    }
    if(dist[x2][y2]>1e8)
    {
        cout<<-1;
        return;
    }
    cout<<dist[x2][y2];
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    //cin>>T;
    int t=0;
    while(t++<T)
    {
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 157196