fun main(omkar: Array<String>) {
    val line = readLine()!!
    val six = line.indexOf(' ')
    val n = line.substring(0, six).toInt()
    val m = line.substring(six + 1).toInt()
    val grid = Array(n) { readLine()!! }
    val dp1 = Array(n) { IntArray(m) { Int.MAX_VALUE } }
    val dp2 = Array(n) { IntArray(m) { Int.MAX_VALUE } }
    dp1[0][0] = if (grid[0][0] == '.') 0 else 1
    dp2[0][0] = 1
    for (y in 0 until n) {
        for (x in 0 until m) {
            if (grid[y][x] == '.') {
                if (y > 0) {
                    dp1[y][x] = dp1[y - 1][x]
                }
                if (x > 0) {
                    dp1[y][x] = Math.min(dp1[y][x], dp1[y][x - 1])
                }
                dp2[y][x] = dp1[y][x] + 1
            } else {
                if (y > 0) {
                    dp2[y][x] = dp2[y - 1][x]
                }
                if (x > 0) {
                    dp2[y][x] = Math.min(dp2[y][x], dp2[y][x - 1])
                }
                dp1[y][x] = dp2[y][x]
            }
        }
    }
    println(dp1[n - 1][m - 1])
}