#include<bits/stdc++.h>
using namespace std;
#define double long double
#define int long long
int n,m,step;
bool p[1145][1145];
bool k[1145][1145];
int sum[1145][1145];
struct node{
int x;
int y;
};
queue <node> s;
int o[4]={0,0,1,-1};
int u[4]={1,-1,0,0};
signed main()
{
cin>>n>>m>>step;
string a;
for (int i=1;i<=n;i++)
{
cin>>a;
for (int j=1;j<=m;j++)
{
if (a[j-1]=='#')
{
p[i][j]=1;
}
}
}
int x2,y2,x3,y3;
cin>>x2>>y2>>x3>>y3;
if (x2==x3 && y2==y3)
{
cout<<0;
return 0;
}
node r;
r.x=x2;
r.y=y2;
k[x2][y2]=1;
s.push(r);
while (!s.empty())
{
for (int i=0;i<=3;i++)
{
for (int j=1;j<=step;j++)
{
int x4=s.front().x+o[i]*j;
int y4=s.front().y+u[i]*j;
if (x4>0 && y4>0 && x4<=n && y4<=m && !p[x4][y4] && !k[x4][y4])
{
k[x4][y4]=1;
sum[x4][y4]=sum[s.front().x][s.front().y]+1;
if (x4==x3 && y4==y3)
{
cout<<sum[x4][y4];
return 0;
}
node r;
r.x=x4;
r.y=y4;
s.push(r);
}
else
{
break;
}
}
}
s.pop();
}
cout<<-1;
return 0;
}