//#pragma GCC optimize("O3")

#include <bits/stdc++.h>

using namespace std;

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr)
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define REP(n) FOR(O, 1, (n))
#define pb push_back
#define f first
#define s second
#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<piii> viii;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MAXN = 500100, MAXK = 23;
const ll MOD = 998244353;
const int INF = 1e9+10;
const ld PI = asin(1) * 2;



int h, w;
ll k;
int x1, y11, x2, y2;

vector<vl> d[4]; // stores the distance from x1, y1
vector<vector<bool>> grid, trav[4]; // grid stores whether a lotus is present at i,j or not.

void dijkstra () {
    priority_queue<pair<ll, pair<int, pii>>, vector<pair<ll, pair<int, pii>>>,
                   greater<pair<ll, pair<int, pii>>>> q;
    FOR(k, 0, 3) {
        d[k][x1][y11] = 0;
        q.push({d[k][x1][y11], {k,{x1,y11}}});
    }
    while (!q.empty ()) {
        auto v = q.top().s;
        q.pop();
        int dir = v.f, x = v.s.f, y = v.s.s;
        if (!trav[dir][x][y]) {
            trav[dir][x][y] = true;

            //cerr << "   d(" << dir << ", " << x << ", " << y << ") = " << d[dir][x][y] << endl;
            // dir == 0  --> up, dir == 1 --> down, dir == 2 --> left
            if (dir == 0 && x > 0 && grid[x-1][y]) {
                if (d[dir][x-1][y] == -1 || d[dir][x-1][y] > d[dir][x][y]+1) {
                    d[dir][x-1][y] = d[dir][x][y]+1;
                    q.push({d[dir][x-1][y], {dir,{x-1,y}}});
                }
            } else if (dir == 1 && x < h-1 && grid[x+1][y]) {
                if (d[dir][x+1][y] == -1 || d[dir][x+1][y] > d[dir][x][y]+1) {
                    d[dir][x+1][y] = d[dir][x][y]+1;
                    q.push({d[dir][x+1][y], {dir,{x+1,y}}});
                }
            } else if (dir == 2 && y > 0 && grid[x][y-1]) {
                if (d[dir][x][y-1] == -1 || d[dir][x][y-1] > d[dir][x][y]+1) {
                    d[dir][x][y-1] = d[dir][x][y]+1;
                    q.push({d[dir][x][y-1], {dir,{x,y-1}}});
                }
            } else if (dir == 3 && y < w-1 && grid[x][y+1]) {
                if (d[dir][x][y+1] == -1 || d[dir][x][y+1] > d[dir][x][y]+1) {
                    d[dir][x][y+1] = d[dir][x][y]+1;
                    q.push({d[dir][x][y+1], {dir,{x,y+1}}});
                }
            }

            ll newD = d[dir][x][y];
            newD = (newD+k-1)/k;
            newD *= k;

            FOR(newDir, 0, 3) {
                if (dir == newDir) continue;

                if (d[newDir][x][y] == -1 || d[newDir][x][y] > newD) {
                    d[newDir][x][y] = newD;
                    q.push({d[newDir][x][y], {newDir,{x,y}}});
                }

                // if (newDir == 0) {
                //     if (d[newDir][x][y] == -1 || d[newDir][x][y] > newD) {
                //         d[newDir][x][y] = newD;
                //         q.push({d[newDir][x][y], {newDir,{x,y}}});
                //     }
                // } else if (newDir == 1) {
                //     if (d[newDir][x][y] == -1 || d[newDir][x][y] > newD) {
                //         d[newDir][x][y] = newD;
                //         q.push({d[newDir][x][y], {newDir,{x,y}}});
                //     }
                // } else if (newDir == 2) {
                //     if (d[newDir][x][y] == -1 || d[newDir][x][y] > newD) {
                //         d[newDir][x][y] = newD;
                //         q.push({d[newDir][x][y], {newDir,{x,y}}});
                //     }
                // } else if (newDir == 3) {
                //     if (d[newDir][x][y] == -1 || d[newDir][x][y] > newD) {
                //         d[newDir][x][y] = newD;
                //         q.push({d[newDir][x][y], {newDir,{x,y}}});
                //     }
                // }


            }

        }

    }
}

int main() {
    // #ifndef ONLINE_JUDGE
    // freopen("../input.txt", "r", stdin);
    // freopen("../output.txt", "w", stdout);
    // #endif
    srand(chrono::steady_clock::now().time_since_epoch().count());
    off;
    cin >> h >> w >> k;
    cin >> x1 >>y11 >> x2 >> y2;
    x1--, y11--, x2--, y2--;
    vector<bool> tmp;
    FOR(i, 0, h-1) {
        tmp.clear();
        FOR(j, 0, w-1) {
            char c; cin >> c;
            tmp.pb(c=='.');
        }
        grid.pb(tmp);
    }

    tmp.clear();
    FOR(j, 0, w-1) tmp.pb(false);
    FOR(k, 0, 3) FOR(i, 0, h-1) trav[k].pb(tmp);

    vl temp;
    FOR(j, 0, w-1) temp.pb(-1);
    FOR(k, 0, 3) FOR(i, 0, h-1) d[k].pb(temp);

    dijkstra();

    ll ans = -1;
    FOR(k, 0, 3) {
        if (d[k][x2][y2] != -1) {
            ans = d[k][x2][y2];
            break;
        }
    }
    if (ans == -1) {
        cout << "-1\n";
        return 0;
    }

    FOR(k, 0, 3) if (d[k][x2][y2] != -1) ans = min(ans, d[k][x2][y2]);

    ans = (ans+k-1)/k;
    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 47428