fun main(args: Array<String>){
    val (H,W) = readLine()!!.split(" ").map{ it.toInt()}
    var dp = Array(H){Array(W){0}}
    var s = Array(H){""}

    for(i in 0 until H){
        s[i] = readLine()!!
    }




    for(i in 0 until H){
        for(j in 0 until W) {
            var fromW: Int  = if(j>0) dp[i][j-1] else 9999
            var fromH: Int = if(i>0) dp[i-1][j] else 9999
            if(j>0){
                if(s[i][j-1] == '.' && s[i][j] == '#'){
                    fromW++
                }
            }
            if(i>0){
                if(s[i-1][j] == '.' && s[i][j] == '#'){
                    fromH++
                }
            }

            if(i ==0 && j==0){
                if(s[0][0] == '#'){
                    dp[0][0] = 1
                }
            } else if (i == 0){
                dp[i][j] = fromW
            } else if (j==0){
                dp[i][j] = fromH
            } else {
                dp[i][j] = Math.min(fromH,fromW)
            }



        }
    }
    println(dp[H-1][W-1])
//    for(i in 0 until H){
//        for(j in 0 until W){
//            print(dp[i][j])
//        }
//        println()
//    }


}