fun main(args: Array<String>) = agc043a()

fun agc043a() {
    val (h, w) = readLine()!!.split(' ').map { it.toInt() }
    val board = Array(h) { readLine()!!.map { it == '.' } }

    val dp = Array(h) { IntArray(w) { Int.MAX_VALUE / 100 } }
    dp[0][0] = if (board[0][0]) 0 else 1

    for (y in 0 until h) {
        for (x in 0 until w) {
            around.map { Pos(it.first + y, it.second + x) }
                .filter { it.y in 0 until h && it.x in 0 until w }
                .forEach {
                    val border = if (board[y][x] == board[it.y][it.x]) 0 else 1
                    dp[it.y][it.x] = Math.min(dp[it.y][it.x], dp[y][x] + border)
                }
        }
    }

    val answer = Math.ceil(dp.last().last().toDouble() / 2).toInt()

    println(answer)
}

private val around = listOf(1 to 0, 0 to 1)

private data class Pos(val y: Int, val x: Int)
