fun main(args : Array<String>) {
    val (h, w) = readLine()!!.split(" ").map { it.toInt() }
    val ss = Array(h) { readLine()!!.toMutableList() }

    val dp = Array(h) { IntArray(w) { 0 } }

    for (i in 0 until h) {
        inner@for (j in 0 until w) {
            if (i == 0 && j == 0) {
                if (ss[i][j] == '#') {
                    dp[i][j] = 1
                } else {
                    dp[i][j] = 0
                }
                continue@inner
            }

            if (i == 0) {
                if (ss[i][j] == '#' && ss[i][j-1] == '.') {
                    dp[i][j] = dp[i][j-1] + 1
                } else {
                    dp[i][j] = dp[i][j-1]
                }
                continue@inner
            }

            if (j == 0) {
                if (ss[i][j] == '#' && ss[i-1][j] == '.') {
                    dp[i][j] = dp[i-1][j] + 1
                } else {
                    dp[i][j] = dp[i-1][j]
                }
                continue@inner
            }

            if (ss[i][j] == '#') {
                val up = if (ss[i-1][j] == '.') dp[i-1][j] + 1 else dp[i-1][j]
                val left = if (ss[i][j-1] == '.') dp[i][j-1] + 1 else dp[i][j-1]
                dp[i][j] = Math.min(up, left)
            } else {
                val up = dp[i-1][j]
                val left = dp[i][j-1]
                dp[i][j] = Math.min(up, left)
            }
        }
    }

    println(dp[h-1][w-1])
}