#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <iomanip>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

#define x1 asnd
#define x2 ajsensaen
#define y1 kaenaje
#define y2 jajfdsfdsf

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;

const int MAX = (int) 1e6 + 1;
vector<vector<char>> grid;
vector<vector<int>> dis;
set<int> row[MAX], col[MAX];
int n, m, k;
int x1, y1, x2, y2;

bool inside(int x, int y) {
    return x >= 0 && x < n && y >= 0 && y < m;
}

bool visitable(int x, int y) {
    return inside(x, y) && grid[x][y] == '.' && dis[x][y] == -1;
}

void visit(int nx, int ny, int x, int y, queue<ii> &q) {
    dis[nx][ny] = dis[x][y] + 1;
    q.emplace(nx, ny);
}

int bfs() {
    queue<ii> q;
    q.emplace(x1, y1);
    dis[x1][y1] = 0;
    while (!q.empty()) {
        ii cur = q.front();
        q.pop();
        int x, y;
        tie(x, y) = cur;
        vector<ii> to_erase;
        for (auto it = col[y].upper_bound(x); it != end(col[y]) && visitable(*it, y) && abs(x - *it) <= k; it++) {
            int nx = *it;
            int ny = y;
            visit(nx, ny, x, y, q);
            to_erase.emplace_back(nx, ny);
        }
        auto it2 = col[y].lower_bound(x);
        bool go = it2 != begin(col[y]);
        if (go) it2 = prev(it2);
        for (; go; ) {
            if (!visitable(*it2, y)) break;
            if (abs(x - *it2) > k) break;
            int nx = *it2;
            int ny = y;
            visit(nx, ny, x, y, q);
            to_erase.emplace_back(nx, ny);
            if (it2 == begin(col[y])) break;
            it2--;
        }
        for (auto it = row[x].upper_bound(y); it != end(row[x]) && visitable(x, *it) && abs(y - *it) <= k; it++) {
            int nx = x;
            int ny = *it;
            visit(nx, ny, x, y, q);
            to_erase.emplace_back(nx, ny);
        }
        auto it3 = row[x].lower_bound(y);
        go = it3 != begin(row[x]);
        if (go) it3 = prev(it3);
        for (; go;) {
            if (!visitable(x, *it3)) break;
            if (abs(y - *it3) > k) break;
            int nx = x;
            int ny = *it3;
            visit(nx, ny, x, y, q);
            to_erase.emplace_back(nx, ny);
            if (it3 == begin(row[x])) break;
            it3--;
        }

        for (auto &each : to_erase) {
            row[each.first].erase(each.second);
            col[each.second].erase(each.first);
        }
    }
    int ans = dis[x2][y2];
    return ans;
}

void solve() {
    scanf("%d %d %d%*c", &n, &m, &k);
    scanf("%d %d %d %d%*c", &x1, &y1, &x2, &y2);
    x1--, y1--, x2--, y2--;
    grid = vector<vector<char>>(n, vector<char>(m));
    dis = vector<vector<int>>(n, vector<int>(m, -1));
    fori (i, 0, n) {
        fori (j, 0, m) {
            row[i].insert(j);
            col[j].insert(i);
            scanf("%c", &grid[i][j]);
        }
        scanf("%*c");
    }
    int ans = bfs();
    printf("%d\n", ans);
}

int main() {
    solve();
    return 0;
}



Measured memory_bytes: 196320