//入力
fun readInts() = readLine()!!.split(" ").map { it.toInt() }
fun readLongs() = readLine()!!.split(" ").map { it.toLong() }
fun readLines(n:Int) = Array(n){readLine()!!}
//宣言
fun goban(h:Int,w:Int) = Array(h){Array(w){0}}
//ループ（breakは return@rep、continueはreturn）
fun rep(n:Int, f:(i:Int)->Unit){    for(i in 0 until n){f(i)}   }
fun rep(from:Int, to:Int, f:(i:Int)->Unit){    for(i in from until to){f(i)}    }

//計算
fun min(vararg values: Int) = values.min()!!
fun min(vararg values: Long) = values.min()!!
fun max(vararg values: Int) = values.max()!!
fun max(vararg values: Long) = values.max()!!

//ブール
fun Boolean.toInt() :Int  = if (this) 1 else 0

//出力
fun Yes(flag:Boolean) = if(flag) println("Yes") else println("No")

fun main(args: Array<String>) {
    val (H,W)=readInts()
    val s = readLines(H)
    val c = goban(H,W)

    rep(1,W){w->
        c[0][w] = c[0][w-1] + (s[0][w-1]!=s[0][w]).toInt()
    }
    rep(1,H){h->
        c[h][0] = c[h-1][0] + (s[h][0]!=s[h-1][0]).toInt()
        rep(1,W){w->
            var a = c[h][w-1] + (s[h][w-1]!=s[h][w]).toInt()
            var b = c[h-1][w] + (s[h-1][w]!=s[h][w]).toInt()
            c[h][w] += min(a,b)
        }
    }

    println(c.last().last()/2 + (s[0][0]=='#' || s.last().last()=='#').toInt())
}
