fun main(args: Array<String>) {
    solve(java.util.Scanner(System.`in`))
}

fun solve(sc: java.util.Scanner) {
    val H = sc.nextInt()
    val W = sc.nextInt()
    val S = Array(H) { sc.next().toCharArray() }

    val A = Array(H) { IntArray(W) }
    for (h in 0 until H) {
        for (w in 0 until W) {
            val prev = mutableListOf<Pair<Int, Int>>()
            if (h > 0) prev.add(Pair(h - 1, w))
            if (w > 0) prev.add(Pair(h, w - 1))
            if (prev.isNotEmpty()) {
                A[h][w] = prev.map {
                    A[it.first][it.second] + if (S[it.first][it.second] == S[h][w]) 0 else 1
                }.min()!!
            }
        }
    }
    val result = (A[H - 1][W - 1] + (if (S[0][0] == '#') 1 else 0) + (if (S[H - 1][W - 1] == '#') 1 else 0)) / 2
    println(result)
}
