#include<bits/stdc++.h>
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define repi(i, a, b) for(int i=(a); i>(b); i--)
#define db(x) (cerr << #x << ": " << (x) << '\n')
#define sync ios_base::sync_with_stdio(false), cin.tie(NULL)
#define tests(t) int t; cin >> t; while(t--)
#define iceil(n, x) (((n) + (x) - 1) / (x))
#define ll long long
#define gcd __gcd
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define sz size()
#define all(v) (v).begin(), (v).end()
#define uni(v) sort(all(v)); (v).erase(unique(all(v)), (v).end());
#define pii pair<int, int>
#define vi vector<int>
#define vpii vector<pii>
#define vvi vector<vi>
#define fi first
#define se second
#define umap unordered_map
#define uset unordered_set
#define pqueue priority_queue
#define si(a) scanf("%d", &a)
#define sll(a) scanf("%lld", &a)
#define bitcount(x) __builtin_popcount(x)
#define cps CLOCKS_PER_SEC
#define PI acos(-1.0)
#define EPS 1e-9
#define mod 1000000007
#define MOD 1000000007
#define N 1005
using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

//#define trace(...) 42

template<typename T>
using minpq = priority_queue<T, vector<T>, greater<T>>;

template<typename T>
using maxpq = priority_queue<T>;

//Returns no. of values x for which ceil(n / x) == y (y must be > 1).
inline ll CC(ll n, ll y) { return iceil(n, y-1) - iceil(n, y); }

//Returns no. of values x for which floor(n / x) == y
inline ll FF(ll n, ll y) { return n / y - n / (y+1); }

//a and b are assumed to be taken modulo p
inline int add(int a, int b, int p = mod){ int c = a + b; if(c >= p) c -= p; return c;}
inline int sub(int a, int b, int p = mod){ int c = a - b; if(c < 0) c += p; return c;}
inline int mul(int a, int b, int p = mod){ return (a * 1ll * b) % p;}

#define int ll

const int inf = 1e9;

int n, m, k;
// char grid[N][N];
// bool vis[N][N][4];
// int diss[N][N][4];

vector<string> grid;
vector<vector<int>> vis, diss;

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

bool isValid(int i, int j) {
    return i >= 0 && j >= 0 && i < n && j < m && grid[i][j] == '.';
}

int bfs(int x1, int y1, int x2, int y2) {
    queue<int> q;
 
    q.push(x1); q.push(y1); q.push(0);
 
    while(q.sz) {
        int a, b, d;
        a = q.front(); q.pop();
        b = q.front(); q.pop();
        d = q.front(); q.pop();
        if(a == x2 && b == y2) return d;
 
        rep(i, 0, 4) {
            int x = a + dx[i], y = b + dy[i];
            int dis = 1;
            while(isValid(x, y) && !vis[x][y] && dis <= k) {
                int dd = d + 1;
                q.push(x); q.push(y); q.push(dd);
                vis[x][y] = 1;
                diss[x][y] = dd;
                x += dx[i], y += dy[i];
                dis++;
            } 
            while(isValid(x, y) && dis <= k) {
                if(vis[x][y]) {
                    if(diss[x][y] != diss[a][b] + 1) break;
                    x += dx[i], y += dy[i]; dis++;
                }
                else {
                    int dd = d + 1;
                    q.push(x); q.push(y); q.push(dd);
                    vis[x][y] = 1;
                    diss[x][y] = dd;
                    x += dx[i]; y += dy[i]; dis++;
                }
            }
        }
    }
    return -1;
}



int32_t main()
{   
    #ifdef CP
        freopen("/home/tarun/Desktop/input.txt", "r", stdin);
//      freopen("/home/tarun/Desktop/output.txt", "w", stdout);
    #endif
    sync;
    clock_t clk = clock();
    cerr << "I will return...\n";
    
    cin >> n >> m >> k;
    int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
    --x1, --y1, --x2, --y2;

    grid.resize(n);
    for(string& s : grid) cin >> s;

    vis.assign(n, vector<int>(m, 0));
    diss.assign(n, vector<int>(m, 0));

    int kk = bfs(x1, y1, x2, y2);
    cout << kk << '\n';
    
    cerr << "...don't you ever hang your head.\n";
    cerr << "Time (in ms): " << double(clock() - clk) * 1000.0 / cps << '\n';
}

//Compile using:
//g++ -o filename.exe --std=c++11 filename.cpp
//Use -D CP for defining a macro CP in the local environment






Measured memory_bytes: 27700