fun <T> splitReadLine(f: ((String) -> T)) = readLine()?.split(" ")?.map(f) ?: TODO()
fun main(args: Array<String>) {
    val (h, w) = splitReadLine(String::toInt)
    val maze = mutableListOf<String>()
    repeat(h) { y ->
        val f = readLine() ?: return
        maze.add(f)
    }
    val dp = Array(h) { Array(w) { -1 } }

    fun calc(c: Char, x: Int, y: Int, xx: Int, yy: Int) {
        val p = maze[yy][xx]
        if (c == '.' && p == '#') {
            if (dp[yy][xx] == -1) {
                dp[yy][xx] = dp[y][x] + 1
            } else {
                dp[yy][xx] = Math.min(dp[yy][xx], dp[y][x] + 1)
            }
        } else {
            if (dp[yy][xx] == -1) {
                dp[yy][xx] = dp[y][x]
            } else {
                dp[yy][xx] = Math.min(dp[yy][xx], dp[y][x])
            }
        }
    }
    (0).until(w).forEach { x ->
        (0).until(h).forEach { y ->
            val c = maze[y][x]
            if (dp[y][x] == -1) {
                dp[y][x] = 0
            }
            if (y + 1 < h) {
                calc(c, x, y, x, y + 1)
            }
            if (x + 1 < w) {
                calc(c, x, y, x + 1, y)
            }
        }
    }
    if (maze[0][0] == '#') {
        dp[h - 1][w - 1]++
    }
    println(dp[h - 1][w - 1].toString())
}