fun min(a:Int,b:Int) = if(a<b) a else b
fun main(args: Array<String>) {
    val (H,W)=readLine()!!.split(" ").map { it.toInt() }
    val s = Array(H){readLine()!!}
    val c = Array(H){Array(W){0}}

    c[0][0] = 0
    for(w in 1 until W){
        c[0][w] = c[0][w-1]
        if(s[0][w-1]!=s[0][w])c[0][w] += 1
    }
    for(h in 1 until H){
        c[h][0] = c[h-1][0]
        if(s[h][0]!=s[h-1][0])c[h][0] += 1

        for(w in 1 until W){
            var a = c[h][w-1]
            if(s[h][w-1]!=s[h][w])a += 1
            var b = c[h-1][w]
            if(s[h-1][w]!=s[h][w])b += 1
            c[h][w] += min(a,b)
        }
    }
    var result=c[H-1][W-1]/2
    if(s[0][0]=='#' || s[H-1][W-1]=='#')result+=1
    println(result)
}