#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int h, w, k;
int x[2], y[2];
string c[1000100];

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

bool infield(int a, int b) {
    return 0 <= a && a < h && 0 <= b && b < w;
}

int solve() {
    P npos[h][w][4];
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            for (int k = 0; k < 4; k++) {
                int nx = i+dx[k], ny = j+dy[k];
                npos[i][j][k] = P(nx, ny);
            }
        }
    }
    int d[h][w];
    memset(d, -1, sizeof(d));
    queue<T> que;
    que.push(T(x[0], y[0], 0));
    d[x[0]][y[0]] = 0;
    for (int i = 0; i < 4; i++) {
        P p = npos[x[0]][y[0]][i];
        P np = npos[x[0]][y[0]][(i+2)%4];
        if (!infield(p.first, p.second) || c[p.first][p.second] == '@') continue;
        npos[p.first][p.second][(i+2)%4] = np;
    }
    while (!que.empty()) {
        T t = que.front(); que.pop();
        int cx = get<0>(t), cy = get<1>(t), cd = get<2>(t);
        for (int i = 0; i < 4; i++) {
            P p = npos[cx][cy][i];
            int ccx = p.first, ccy = p.second;
            //cerr << cx << " " << cy << " " << ccx << " " << ccy << endl;
            while (infield(ccx, ccy) && c[ccx][ccy] == '.' && abs(cx-ccx)+abs(cy-ccy)<=k && (d[ccx][ccy] < 0 || d[ccx][ccy] == cd+1)) {
                if (d[ccx][ccy] < 0) {
                    d[ccx][ccy] = cd+1;
                    for (int j = 0; j < 4; j++) {
                        P _p = npos[ccx][ccy][j];
                        P _np = npos[ccx][ccy][(j+2)%4];
                        if (!infield(_p.first, _p.second) || c[_p.first][_p.second] == '@') continue;
                        npos[_p.first][_p.second][(j+2)%4] = _np;
                    }
                    que.push(T(ccx, ccy, cd+1));
                }
                P np = npos[ccx][ccy][i];
                ccx = np.first;
                ccy = np.second;
            }
            /*
            for (int j = 0; j < h; j++) {
                for (int k = 0; k < w; k++) {
                    cerr << d[j][k] << " ";
                }
                cerr << endl;
            }
            cerr << endl;
            */
        }
    }
    return d[x[1]][y[1]];
}

void input() {
    cin >> h >> w >> k;
    for (int i = 0; i < 2; i++) {
        cin >> x[i] >> y[i];
        x[i]--;
        y[i]--;
    }
    for (int i = 0; i < h; i++) cin >> c[i];
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 63820