#include <bits/stdc++.h>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T1, class T2>
ostream &operator<<(ostream &s, pair<T1, T2> P)
{
    return s << '<' << P.first << ", " << P.second << '>';
}
template <class T>
ostream &operator<<(ostream &s, vector<T> P)
{
    for (int i = 0; i < P.size(); ++i)
    {
        if (i > 0)
        {
            s << " ";
        }
        s << P[i];
    }
    return s;
}
template <class T>
ostream &operator<<(ostream &s, vector<vector<T>> P)
{
    for (int i = 0; i < P.size(); ++i)
    {
        s << endl
          << P[i];
    }
    return s << endl;
}
template <class T>
ostream &operator<<(ostream &s, set<T> P)
{
    EACH(it, P) { s << "<" << *it << "> "; }
    return s << endl;
}
template <class T1, class T2>
ostream &operator<<(ostream &s, map<T1, T2> P)
{
    EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; }
    return s << endl;
}
template <class T>
void show(vector<T> v)
{
    for (int i = 0; i < v.size(); i++)
    {
        cerr << v[i] << " ";
    }
    cerr << "\n";
}
typedef long long ll;

struct cor
{
    int x;
    int y;
    int depth;
};

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int h, w, k;
    cin >> h >> w >> k;
    int sx, sy, gx, gy;
    cin >> sx >> sy >> gx >> gy;
    sx--, sy--, gx--, gy--;
    vector<string> grid(h);
    for (int i = 0; i < h; i++)
    {
        cin >> grid[i];
    }
    queue<cor> q;
    q.push({sx, sy, 0});
    vector<vector<int>> flag(h, vector<int>(w, INF));
    flag[sx][sy] = 0;
    while (!q.empty())
    {
        cor v = q.front();
        q.pop();
        int x = v.x;
        int y = v.y;
        int d = v.depth;
        for (int i = 1; i <=k; i++)
        {
            int nx = x;
            int ny = y + i;
            if(ny < 0 || ny>=w || flag[nx][ny] < d + 1 || grid[nx][ny] =='@' ) {
                break;
            }
            if (flag[nx][ny] >d+1){
                flag[nx][ny] = d + 1;
                q.push({nx, ny, d + 1});
            }
        }
        for (int i = 1; i <= k; i++)
        {
            int nx = x;
            int ny = y - i;
            if (ny < 0 || ny >= w || flag[nx][ny] < d + 1 || grid[nx][ny] == '@')
            {
                break;
            }
            if (flag[nx][ny] > d + 1)
            {
                flag[nx][ny] = d + 1;
                q.push({nx, ny, d + 1});
            }
        }
        for (int i = 1; i <= k; i++)
        {
            int nx = x+i;
            int ny = y ;
            if (nx < 0 || nx >= h || flag[nx][ny] < d + 1 || grid[nx][ny] == '@')
            {
                break;
            }
            if (flag[nx][ny] > d + 1)
            {
                flag[nx][ny] = d + 1;
                q.push({nx, ny, d + 1});
            }
        }
        for (int i = 1; i <= k; i++)
        {
            int nx = x - i;
            int ny = y;
            if (nx < 0 || nx >= h || flag[nx][ny] < d + 1 || grid[nx][ny] == '@')
            {
                break;
            }
            if (flag[nx][ny] > d + 1)
            {
                flag[nx][ny] = d + 1;
                q.push({nx, ny, d + 1});
            }
        }
    }
    /*  for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            cerr << flag[i][j] << " ";
        }
        cerr << '\n';
    }*/
    if (flag[gx][gy] == INF)
    {
        cout << -1 << '\n';
    }
    else
        cout << flag[gx][gy] << endl;

    return 0;
}

Measured memory_bytes: 19820