#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define ss second
#define ff first
#define INF 300000000000001
#define ll_max 9000000000000000000
#define mod 998244353
#define PI 3.14159265358979323846L
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define db(args...) {string _ss = #args; replace(_ss.begin(), _ss.end(), ',' , ' '); stringstream ___s(_ss) ; debug(___s, args);}
using namespace std;
typedef vector<pair<ll,ll> > vll;
typedef vector<pair<int,int> > vii ;
typedef pair<ll,ll> pll;
const ll N = 100001;
const ll M = 21;
struct point {
    ll x, y, cur;
    char dir;
    bool operator == (const point b)
    {
        if(this -> x == b.x && this -> y == b.y) return 1;
        return 0;
    }
    bool operator != (const point b)
    {
        return !(*this == b);
    }
    friend bool operator < (const point a, const point b)
    {
        if(a.x != b.x)
            return a.x < b.x;
        if(a.y != b.y)
            return a.y < b.y;
        return int(a.dir) < int(b.dir);
    }
};

void debug(stringstream &s){}
template <typename T, typename... Args>
void debug(stringstream &s, T a, Args... args)
{
    string word;
    s >> word;
    cout << word << " = " << a << endl;
    debug(s, args...);
}

ll fast_exp(ll x, ll n)
{
    if(n == 0) return 1;
    ll ans;
    if(n % 2 == 0)
    {
         ans = fast_exp(x, n / 2);
         ans = ans * ans % mod;
    }
    else ans = fast_exp(x, n - 1) * x % mod;
    return ans;
}

int main()
{
    fast;
    int _ = 1;
    //cin >> _;
    while(_--)
    {
        ll n, m, x = 1, y = INF, ans = 0, k, x1, x2, y1, y2;
        cin >> n >> m >> k;
        cin >> x1 >> y1 >> x2 >> y2;
        bool v[n + 1][m + 1] = {};
        ll dist[n + 1][m + 1]= {};
        char c[n + 1][m + 1];
        for(int i = 1; i <= n; i++)
        {
            for(int j = 1; j <= m; j++)
            {
                cin >> c[i][j];
                if(c[i][j] != '.')
                    v[i][j] = 1;
                dist[i][j] = INF;
            }
        }
        queue<pll> Q;
        pll tmp = {x1, y1};
        Q.push(tmp);
        dist[tmp.ff][tmp.ss] = 0;
        while(!Q.empty())
        {
            tmp = Q.front();
            Q.pop();
            for(int i = 1; i <= k; i++)
            {
                if(tmp.ss + i > m || c[tmp.ff][tmp.ss + i] == '@') break;
                if(dist[tmp.ff][tmp.ss + i] > dist[tmp.ff][tmp.ss])
                    dist[tmp.ff][tmp.ss + i] = min(dist[tmp.ff][tmp.ss + i], dist[tmp.ff][tmp.ss] + 1);
                else break;
                if(!v[tmp.ff][tmp.ss + i])
                    Q.push({tmp.ff, tmp.ss + i});
                v[tmp.ff][tmp.ss + i] = 1;
            }
            for(int i = 1; i <= k; i++)
            {
                if(tmp.ss - i <= 0 || c[tmp.ff][tmp.ss - i] == '@') break;
                if(dist[tmp.ff][tmp.ss - i] > dist[tmp.ff][tmp.ss])
                    dist[tmp.ff][tmp.ss - i] = min(dist[tmp.ff][tmp.ss - i], dist[tmp.ff][tmp.ss] + 1);
                else break;
                if(!v[tmp.ff][tmp.ss - i])
                    Q.push({tmp.ff, tmp.ss - i});
                v[tmp.ff][tmp.ss - i] = 1;
            }
            for(int i = 1; i <= k; i++)
            {
                if(tmp.ff + i > n || c[tmp.ff + i][tmp.ss] == '@') break;
                if(dist[tmp.ff + i][tmp.ss] > dist[tmp.ff][tmp.ss])
                    dist[tmp.ff + i][tmp.ss] = min(dist[tmp.ff + i][tmp.ss], dist[tmp.ff][tmp.ss] + 1);
                else break;
                if(!v[tmp.ff + i][tmp.ss])
                    Q.push({tmp.ff + i, tmp.ss});
                v[tmp.ff + i][tmp.ss] = 1;
            }
            for(int i = 1; i <= k; i++)
            {
                if(tmp.ff - i <= 0 || c[tmp.ff - i][tmp.ss] == '@') break;
                if(dist[tmp.ff - i][tmp.ss] > dist[tmp.ff][tmp.ss])
                    dist[tmp.ff - i][tmp.ss] = min(dist[tmp.ff - i][tmp.ss], dist[tmp.ff][tmp.ss] + 1);
                else break;
                if(!v[tmp.ff - i][tmp.ss])
                    Q.push({tmp.ff - i, tmp.ss});
                v[tmp.ff - i][tmp.ss] = 1;
            }
        }
        if(v[x2][y2])
            cout << dist[x2][y2] << "\n";
        else
            cout << "-1\n";
    }
     return 0;
}


Measured memory_bytes: 22200