import java.util.PriorityQueue

fun main(args: Array<String>) {
    val (H, W) = readInputLine().split(" ").map { it.toInt() }
    val map = Array(H) { readInputLine().toCharArray() }

    val queue = PriorityQueue<Pair<Int, Pair<Int, Int>>>(H * W) { x, y -> x.first.compareTo(y.first) }
    val costMap = Array(H) { IntArray(W) { Int.MAX_VALUE } }

    var ans = Int.MAX_VALUE

    queue.add(Pair(if (map[0][0] == '#') 1 else 0, Pair(0, 0)))

    while (queue.isNotEmpty()) {
        val (cost, pos) = queue.poll()!!

        if (pos.first == H - 1 && pos.second == W - 1) {
            ans = Math.min(ans, cost)
        }

        if (pos.first < H - 1) {
            val newCost = if (map[pos.first][pos.second] != map[pos.first + 1][pos.second] && map[pos.first + 1][pos.second] == '#') {
                cost + 1
            } else {
                cost
            }
            if (newCost < costMap[pos.first + 1][pos.second]) {
                costMap[pos.first + 1][pos.second] = newCost
                queue.add(Pair(newCost, Pair(pos.first + 1, pos.second)))
            }
        }

        if (pos.second < W - 1) {
            val newCost =
            if (map[pos.first][pos.second] != map[pos.first][pos.second + 1] && map[pos.first][pos.second + 1] == '#') {
                cost + 1
            } else {
                cost
            }
            if (newCost < costMap[pos.first][pos.second + 1]) {
                costMap[pos.first][pos.second + 1] = newCost
                queue.add(Pair(newCost, Pair(pos.first, pos.second + 1)))
            }
        }
    }

    println(ans)
}

fun readInputLine(): String {
    return readLine()!!
}
