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

namespace AtCoder
{
    struct Point
    {
        public int X;
        public int Y;
        public Point(int x, int y)
        {
            X = x;
            Y = y;
        }
    }

    enum Direction
    {
        None,
        North,
        East,
        South,
        West
    }

    class Abc170F
    {
        public static void Main()
        {
            var hwk = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();

            var height = hwk[0];
            var width = hwk[1];
            var k = hwk[2];

            var xy = Console.ReadLine().Split(' ').Select(i => int.Parse(i) - 1).ToArray();

            var y0 = xy[0];
            var x0 = xy[1];
            var y1 = xy[2];
            var x1 = xy[3];
            var map = new int[height][];
            for (int i = 0; i < height; i++)
                map[i] = Console.ReadLine().Select(c => c == '@' ? int.MinValue : int.MaxValue).ToArray();
            var points = new HashSet<Point>(new[] { new Point(x0, y0) });
            map[y0][x0] = 0;

            var cost = 0;
            while (points.Any())
            {
                cost++;
                var nextPoints = new HashSet<Point>();
                foreach (var p in points)
                {
                    if (p.X == x1 && p.Y == y1)
                    {
                        Console.WriteLine(cost - 1);
                        return;
                    }

                    void MoveTo(Direction direction)
                    {
                        int dx = 0, dy = 0;
                        switch (direction)
                        {
                            case Direction.North:
                                dy--;
                                break;
                            case Direction.South:
                                dy++;
                                break;
                            case Direction.East:
                                dx++;
                                break;
                            case Direction.West:
                                dx--;
                                break;
                        }

                        var next = p;
                        for (int i = 0; i < k; i++)
                        {
                            next.X += dx;
                            next.Y += dy;
                            if (next.X < 0 || width <= next.X ||
                                next.Y < 0 || height <= next.Y || map[next.Y][next.X] < cost)
                                return;
                            if (map[next.Y][next.X] == cost)
                                continue;
                            map[next.Y][next.X] = cost;
                            nextPoints.Add(next);
                        }
                    }
                    MoveTo(Direction.North);
                    MoveTo(Direction.South);
                    MoveTo(Direction.East);
                    MoveTo(Direction.West);
                }
                points = nextPoints;
            }
            Console.WriteLine(-1);
        }
    }
}


Measured memory_bytes: 57332