#include <bits/stdc++.h>

using namespace std;

using Point = pair<int, int>;
vector<Point> dirs = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};

int solveNaive(int k, int i1, int j1, int i2, int j2, vector<string> a) {
    int n = a.size();
    int m = a[0].size();
    vector<Point> q;
    vector<vector<int>> dist(n, vector<int>(m, -1));
    q.push_back({i1, j1});
    dist[i1][j1] = 0;
    for (int qi = 0; qi < q.size(); qi++) {
        auto cur = q[qi];
        for (int curDi = 0; curDi < dirs.size(); curDi++) {
            for (int c = 1; c <= k; c++) {
                int i = cur.first + c*dirs[curDi].first;
                int j = cur.second + c*dirs[curDi].second;
                if (0 <= i && i < n && 0 <= j && j < m && a[i][j] == '.' ) {
                    if (dist[i][j] == -1) {
                        dist[i][j] = dist[cur.first][cur.second] + 1;
                        q.push_back({i, j});
                    }
                } else {
                    break;
                }
            }
        }
    }
    return dist[i2][j2];
}

int solve(int k, int i1, int j1, int i2, int j2, vector<string> a) {
    int n = a.size();
    int m = a[0].size();
    vector<Point> q;
    vector<vector<int>> dist(n, vector<int>(m, -1));
    vector<set<int>> freeI(n), freeJ(m);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            freeI[i].insert(j);
            freeJ[j].insert(i);
        }
    }
    auto add = [&](int i, int j, int d) {
        if (dist[i][j] != -1) {
            return;
        }
        dist[i][j] = d;
        freeI[i].erase(j);
        freeJ[j].erase(i);
        q.push_back({i, j});
    };
    auto findSet = [&] (set<int> &st, int v, int mx) -> Point {
        auto it = st.upper_bound(v);
        int from = it == st.begin() ? -1 : *prev(it);
        int to = it == st.end() ? mx : *it;
        return {from, to};
    };
    auto findStart = [&] (int i, int j, int di) -> Point {
        auto dr = dirs[di];
        if (dr.first != 0) {
            auto pr = findSet(freeJ[j], i, n);
            return { dr.first == 1 ? pr.second : pr.first, j };
        }
        auto pr = findSet(freeI[i], j, m);
        return { i, dr.second == 1 ? pr.second : pr.first };
    };
    add(i1, j1, 0);
    for (int qi = 0; qi < q.size(); qi++) {
        auto cur = q[qi];
        for (int curDi = 0; curDi < dirs.size(); curDi++) {
            auto pr = findStart(cur.first, cur.second, curDi);
            int i = pr.first;
            int j = pr.second;
            while (true) {
                if (abs(i-cur.first) + abs(j-cur.second) <= k && 0 <= i && i < n && 0 <= j && j < m && a[i][j] == '.') {
                    add(i, j, dist[cur.first][cur.second] + 1);
                } else {
                    break;
                }
                i += dirs[curDi].first;
                j += dirs[curDi].second;
            }
        }
    }
    return dist[i2][j2];
}

int test() {
    int n = 6;
    int m = 6;
    int mxK = 7;
    while (true) {
        int k = rand() % mxK + 1;
        vector<string> a(n, string(m, '.'));
        int i1 = rand()%n;
        int j1 = rand()%m;
        int i2 = rand()%n;
        int j2 = rand()%m;
        if (i1 == i2 && j1 == j2) {
            continue;
        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                if ((i == i1 && j == j1) || (i == i2 && j == j2)) {
                    continue;
                }
                if (rand()%2 == 0) {
                    a[i][j] = '@';
                }
            }
        }
        auto actual = solve(k, i1, j1, i2, j2, a);
        auto expected = solveNaive(k, i1, j1, i2, j2, a);
        if (actual != expected) {
            cout << "expected " << expected << endl;
            cout << "actual " << actual << endl;
            cout << n << " " << m << " " << k << endl;
            cout << i1+1 << " " << j1+1 << " " << i2+1 << " " << j2+1 << endl;
            for (int i = 0; i < n; i++) {
                cout << a[i] << endl;
            }
            return 1;
        }
    }
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    //return test();
    int n, m, k;
    int i1, j1, i2, j2;
    cin >> n >> m >> k >> i1 >> j1 >> i2 >> j2;
    i1--; j1--; i2--; j2--;
    vector<string> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    cout << solve(k, i1, j1, i2, j2, a) << endl;
    //cout << solveNaive(k, i1, j1, i2, j2, a) << endl;
}



Measured memory_bytes: 149812