using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;

namespace contest_Csharp
{
    class Program
    {


        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var vals = Console.ReadLine().Split(' ').
                Select(x => int.Parse(x)).ToList();
            int H = vals[0], W = vals[1], K = vals[2];
            var vals2 = Console.ReadLine().Split(' ').
                Select(x => int.Parse(x)).ToList();
            (int x, int y) p1 = (vals2[0] - 1, vals2[1] - 1);
            (int x, int y) p2 = (vals2[2] - 1, vals2[3] - 1);
            List<string> pond = new List<string>();
            for (int i = 0; i < H; i++)
            {
                pond.Add(Console.ReadLine());
            }
            int[,] field = new int[H, W];
            for (int i = 0; i < H; i++)
            {
                for (int m = 0; m < W; m++)
                {
                    field[i, m] = int.MaxValue / 2;
                }
            }
            field[p1.x, p1.y] = 0;
            var bfsqueue = new Queue<(int x, int y)>();
            bfsqueue.Enqueue(p1);
            while (bfsqueue.Count()!=0)
            {
                (int x, int y) cp=bfsqueue.Dequeue();
                for (int i = 1; i < K+1; i++)
                {
                    if (cp.x+i>=H || pond[cp.x + i][cp.y] == '@' ||
                        field[cp.x, cp.y] + 1 > field[cp.x + i, cp.y])
                    {
                        break;
                    }
                    if (field[cp.x, cp.y] + 1 < field[cp.x + i, cp.y])
                    {
                        field[cp.x + i, cp.y] = field[cp.x, cp.y] + 1;
                        bfsqueue.Enqueue((cp.x + i, cp.y));
                    }
                }
                for (int i = 1; i < K+1; i++)
                {
                    if (cp.x-i < 0 || pond[cp.x - i][cp.y] == '@' ||
                        field[cp.x, cp.y] + 1 > field[cp.x - i, cp.y])
                    {
                        break;
                    }
                    if (field[cp.x, cp.y] + 1 < field[cp.x - i, cp.y])
                    {
                        field[cp.x - i, cp.y] = field[cp.x, cp.y] + 1;
                        bfsqueue.Enqueue((cp.x - i, cp.y));
                    }
                }
                for (int j = 1; j < K+1; j++)
                {
                    if (cp.y + j >= W || pond[cp.x][cp.y+j] == '@' ||
                        field[cp.x, cp.y] + 1 > field[cp.x, cp.y+j])
                    {
                        break;
                    }
                    if (field[cp.x, cp.y] + 1 < field[cp.x , cp.y+j])
                    {
                        field[cp.x, cp.y+j] = field[cp.x, cp.y] + 1;
                        bfsqueue.Enqueue((cp.x , cp.y+j));
                    }
                }
                for (int j = 1; j < K+1; j++)
                {
                    if (cp.y - j < 0 || pond[cp.x][cp.y - j] == '@' ||
                        field[cp.x, cp.y] + 1 > field[cp.x, cp.y - j])
                    {
                        break;
                    }
                    if (field[cp.x, cp.y] + 1 < field[cp.x, cp.y - j])
                    {
                        field[cp.x, cp.y - j] = field[cp.x, cp.y] + 1;
                        bfsqueue.Enqueue((cp.x, cp.y - j));
                    }
                }
            }

            var ans = (field[p2.x, p2.y]< int.MaxValue / 2)? field[p2.x, p2.y] :-1;


            Console.WriteLine(ans);
            Console.Out.Flush();
        }




    }
}




Measured memory_bytes: 39100