import java.util.*

data class Item(var y:Int, var x:Int, var c:Int)

fun main() {
    val (h,w,k) = readLine()!!.split(" ").map { it.toInt() }
    var (y1,x1,y2,x2) = readLine()!!.split(" ").map { it.toInt() }
    x1--
    y1--
    x2--
    y2--
    val dirs = arrayOf(-1 to 0, 1 to 0, 0 to -1, 0 to 1)
    // 0 - 빔, 1 - 채움, 2 - 장애물
    val board = Array(h){IntArray(w)}
    val vv = Array(h){IntArray(w){10000000} }
    for(i in 0 until h) {
        val row = readLine()!!
        for(j in 0 until w) {
            if(row[j] == '.') continue
            board[i][j] = 2
        }
    }

    val q = LinkedList<Item>()
    var ans = -1
    q.add(Item(y1, x1, 0))

    while (q.isNotEmpty()) {
        val v = q.poll()
//        println("Y : ${v.y}, X : ${v.x} - ${v.c}")
        if(v.x == x2 && v.y == y2) {
            ans = v.c
            break
        }
        for((dy, dx) in dirs) {
            for(i in 1..k) {
                val cy = dy * i + v.y
                val cx = dx * i + v.x
                if(cy < 0 || cy >= h || cx < 0 || cx >= w)
                    break
                if(board[cy][cx] == 2)
                    break
                if(board[cy][cx] == 1 && vv[cy][cx] < v.c + 1)
                    break
                board[cy][cx] = 1
                if(vv[cy][cx] > v.c + 1)
                    q.add(Item(cy, cx, v.c + 1))
                vv[cy][cx] = v.c + 1
            }
        }
    }
    print(ans)

}