import scala.collection.mutable.Queue

object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val h, w, k = sc.nextInt()
  val x1, y1, x2, y2 = sc.nextInt()-1
  val c = Array.fill(h)(sc.next()).map(_.map(_ == '@').toArray)

  def bfs(sx: Int, sy: Int, w: Int, h: Int, g: Array[Array[Boolean]]): Array[Array[Int]] = {
    val ans = Array.fill(w, h)(-1)
    val queue = Queue((sx, sy))
    ans(sx)(sy) = 0
    queue.enqueue((sx, sy))

    val d = List((1,0),(-1,0),(0,1),(0,-1))
    while (queue.nonEmpty) {
      val (x1, y1) = queue.dequeue
      for ((dx, dy) <- d) {
        var continue = true
        for (f <- 1 to k if continue) {
          val x2 = x1 + dx * f
          val y2 = y1 + dy * f
          if (x2 < 0 || w <= x2 || y2 < 0 || h <= y2 || g(x2)(y2) || ans(x2)(y2) == ans(x1)(y1) + 1) {
            continue = false
          } else {
            if (0 <= x2 && x2 < w && 0 <= y2 && y2 < h && ans(x2)(y2) == -1) {
              ans(x2)(y2) = ans(x1)(y1) + 1
              queue.enqueue((x2, y2))
            }
          }
        }
      }
    }
    ans
  }

  println(bfs(x1, y1, h, w, c)(x2)(y2))
}
