#include <bits/stdc++.h>
using namespace std;
#define m_p make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define fi first
#define se second
typedef long long ll;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
mt19937 rnf(2106);
const int N = 1000006;

int n, m, k;
char** a;
set<int> t[N], s[N];
set<int> tt[N], ss[N];

void han(int x, int y)
{
    t[x].erase(y);
    s[y].erase(x);
}

int** d;
bool** c;

void solv()
{
    scanf("%d%d%d", &n, &m, &k);
    pair<int, int> start, finish;
    scanf("%d%d%d%d", &start.fi, &start.se, &finish.fi, &finish.se);
    a = new char*[n + 5];
    for (int i = 0; i < n + 5; ++i)
        a[i] = new char[m + 5];
    for (int i = 1; i <= n; ++i)
        scanf(" %s", (a[i] + 1));
    for (int i = 1; i <= n; ++i)
    {
        for (int j = 1; j <= m; ++j)
        {
            if (a[i][j] != '.')
            {
                tt[i].insert(j);
                ss[j].insert(i);
            }
            else
            {
                t[i].insert(j);
                s[j].insert(i);
            }
        }
    }

    c = new bool*[n + 5];
    for (int i = 0; i < n + 5; ++i)
    {
        c[i] = new bool[m + 5];
        for (int j = 0; j < m + 5; ++j)
            c[i][j] = false;
    }
    d = new int*[n + 5];
    for (int i = 0; i < n + 5; ++i)
    {
        d[i] = new int[m + 5];
        for (int j = 0; j < m + 5; ++j)
            d[i][j] = 0;
    }
    queue<pair<int, int> > q;
    c[start.fi][start.se] = true;
    d[start.fi][start.se] = 0;
    han(start.fi, start.se);
    q.push(start);
    while (!q.empty())
    {
        pair<int, int> u = q.front();
        q.pop();
        if (u == finish)
        {
            printf("%d\n", d[u.fi][u.se]);
            return;
        }
        auto it = tt[u.fi].upper_bound(u.se);
        int hh;
        if (it == tt[u.fi].end())
            hh = N;
        else
            hh = *it;
        while (1)
        {
            auto it = t[u.fi].upper_bound(u.se);
            if (it == t[u.fi].end())
                break;
            pair<int, int> h = m_p(u.fi, *it);
            if (abs(h.fi - u.fi) + abs(h.se - u.se) <= k && h.se < hh)
            {
                c[h.fi][h.se] = true;
                d[h.fi][h.se] = d[u.fi][u.se] + 1;
                han(h.fi, h.se);
                q.push(h);
            }
            else
                break;
        }
        it = tt[u.fi].upper_bound(u.se);
        if (it == tt[u.fi].begin())
            hh = -N;
        else
        {
            --it;
            hh = *it;
        }
        while (1)
        {
            if (t[u.fi].empty())
                break;
            auto it = t[u.fi].upper_bound(u.se);
            if (it == t[u.fi].begin())
                break;
            --it;
            pair<int, int> h = m_p(u.fi, *it);
            if (abs(h.fi - u.fi) + abs(h.se - u.se) <= k && h.se > hh)
            {
                c[h.fi][h.se] = true;
                d[h.fi][h.se] = d[u.fi][u.se] + 1;
                han(h.fi, h.se);
                q.push(h);
            }
            else
                break;
        }
        it = ss[u.se].upper_bound(u.fi);
        if (it == ss[u.se].end())
            hh = N;
        else
            hh = *it;
        while (1)
        {
            auto it = s[u.se].upper_bound(u.fi);
            if (it == s[u.se].end())
                break;
            pair<int, int> h = m_p(*it, u.se);
            if (abs(h.fi - u.fi) + abs(h.se - u.se) <= k && h.fi < hh)
            {
                c[h.fi][h.se] = true;
                d[h.fi][h.se] = d[u.fi][u.se] + 1;
                han(h.fi, h.se);
                q.push(h);
            }
            else
                break;
        }
        it = ss[u.se].upper_bound(u.fi);
        if (it == ss[u.se].begin())
            hh = -N;
        else
        {
            --it;
            hh = *it;
        }
        while (1)
        {
            if (s[u.se].empty())
                break;
            auto it = s[u.se].upper_bound(u.fi);
            if (it == s[u.se].begin())
                break;
            --it;
            pair<int, int> h = m_p(*it, u.se);
            if (abs(h.fi - u.fi) + abs(h.se - u.se) <= k && h.fi > hh)
            {
                c[h.fi][h.se] = true;
                d[h.fi][h.se] = d[u.fi][u.se] + 1;
                han(h.fi, h.se);
                q.push(h);
            }
            else
                break;
        }
    }
    printf("-1\n");
}

int main()
{
    #ifdef SOMETHING
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #endif // SOMETHING
    //ios_base::sync_with_stdio(false), cin.tie(0);
    solv();
    return 0;
}

//while ((double)clock() / CLOCKS_PER_SEC <= 0.9){}


Measured memory_bytes: 315384