fun main(args: Array<String>) {
    val (h, w) = readLine()!!.split(" ").map { it.toInt() }
    val items = (0 until h).map {
        readLine()!!.toCharArray().map {
            when (it) {
                '.' -> true
                '#' -> false
                else -> throw IllegalStateException()
            }
        }
    }

    val map = mutableMapOf<String, Int>()
    for (i in (h - 1) downTo 0) {
        for (j in (w - 1) downTo 0) {
            val isGood = items[i][j]

            if (i == (h - 1) && j == (w - 1)) {
                map["$i-$j"] = if (isGood) 0 else 1
                continue
            }

            val fromDown = if (i != (h - 1)) {
                map["${i + 1}-$j"]!! + if (isGood != items[i + 1][j]) 1 else 0
            } else {
                5000
            }
            val fromEnd = if (j != (w - 1)) {
                map["$i-${j + 1}"]!! + if (isGood != items[i][j + 1]) 1 else 0
            } else {
                5000
            }
            map["$i-$j"] = Math.min(fromDown, fromEnd)
        }
    }

    val result = Math.ceil(map["0-0"]!!.toDouble() / 2.0).toInt()
    println(result)
}