#include <algorithm>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
using namespace std;
typedef long long Int;
typedef pair<int, int> P;
Int h, w, k;
string field[1100000];
vector<vector<Int> > dist;

Int dx[] = {0, 1, 0, -1};
Int dy[] = {1, 0, -1, 0};

void bfs(int sx, int sy)
{
    queue<P> q;
    dist[sx][sy] = 0;
    q.push(P(sx, sy));
    while (!q.empty()) {
        P from = q.front();
        q.pop();
        int fx = from.first, fy = from.second;
        for (int d = 0; d < 4; d++) {
            for (int j = 1; j <= k; j++) {
                int tx = fx + dx[d] * j;
                int ty = fy + dy[d] * j;
                if (tx < 0 || tx >= h || ty < 0 || ty >= w)
                    break;
                if (field[tx][ty] == '@')
                    break;
                if (dist[tx][ty] != -1 && dist[tx][ty] <= dist[fx][fy])
                    break;
                if (dist[tx][ty] != -1)
                    continue;
                dist[tx][ty] = dist[fx][fy] + 1;
                q.push(P(tx, ty));
            }
        }
    }
}

int main()
{
    Int sx, sy, gx, gy;
    cin >> h >> w >> k;
    dist = vector<vector<Int> >(h, vector<Int>(w, -1));
    cin >> sx >> sy >> gx >> gy;
    sx--, sy--, gx--, gy--;
    for (int i = 0; i < h; i++) {
        cin >> field[i];
    }

    bfs(sx, sy);
    cout << dist[gx][gy] << endl;
  return 0;
}
