fun main(args:Array<String>) {
    val (h,w) = readLine()!!.split(" ").map { it.toInt() }
    val dp = Array(h+1){Array(w+1){Int.MAX_VALUE / 2} }
    val board = Array(h){CharArray(w)}
    val dirs = arrayOf(1 to 0, 0 to 1)

    for(i in 0 until h) {
        board[i] = readLine()!!.toCharArray()
    }

    dp[0][0] = if(board[0][0] == '#') 1 else 0


    for(y in 0 until h) {
        for(x in 0 until w) {
            val cur = board[y][x]
            for((dy, dx) in dirs) {
                val ny = dy + y
                val nx = dx + x
                if(ny >= h || nx >= w) continue
                val next = board[ny][nx]
                if(cur == '#') {
                    if(dp[ny][nx] > dp[y][x]) {
                        dp[ny][nx] = dp[y][x]
                    }
                } else {
                    if(next == '#') {
                        if(dp[ny][nx] > dp[y][x] + 1) {
                            dp[ny][nx] = dp[y][x] + 1
                        }
                    } else {
                        if(dp[ny][nx] > dp[y][x]) {
                            dp[ny][nx] = dp[y][x]
                        }
                    }
                }
            }
        }
    }
    print(dp[h-1][w-1])
}