using System;
using System.Collections.Generic;
using CompLib.Util;

public class Program
{
    private int H, W, K;
    private int X1, Y1, X2, Y2;
    private char[][] C;

    private int[] Dx = new int[] {0, 1, 0, -1};

    private int[] Dy = new int[] {1, 0, -1, 0};

    public void Solve()
    {
        var sc = new Scanner();
        H = sc.NextInt();
        W = sc.NextInt();
        K = sc.NextInt();
        X1 = sc.NextInt() - 1;
        Y1 = sc.NextInt() - 1;
        X2 = sc.NextInt() - 1;
        Y2 = sc.NextInt() - 1;
        C = new char[H][];
        for (int i = 0; i < H; i++)
        {
            C[i] = sc.NextCharArray();
        }


        var xq = new Queue<int>();
        var yq = new Queue<int>();
        int[,] t = new int[H, W];
        for (int i = 0; i < H; i++)
        {
            for (int j = 0; j < W; j++)
            {
                t[i, j] = int.MaxValue;
            }
        }

        t[X1, Y1] = 0;
        xq.Enqueue(X1);
        yq.Enqueue(Y1);

        while (xq.Count > 0)
        {
            var xx = xq.Dequeue();
            var yy = yq.Dequeue();
            for (int i = 0; i < 4; i++)
            {
                for (int j = 1; j <= K; j++)
                {
                    int nx = xx + Dx[i] * j;
                    int ny = yy + Dy[i] * j;
                    if (nx < 0 || nx >= H) break;
                    if (ny < 0 || ny >= W) break;
                    if (C[nx][ny] == '@') break;
                    if (t[nx, ny] <= t[xx, yy]) break;
                    if (t[xx, yy] + 1 < t[nx, ny])
                    {
                        xq.Enqueue(nx);
                        yq.Enqueue(ny);
                        t[nx, ny] = t[xx, yy] + 1;
                    }
                }
            }
        }

        if (t[X2, Y2] == int.MaxValue) Console.WriteLine("-1");
        else Console.WriteLine(t[X2, Y2]);
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 40752