import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))
    val Array(h, w) = in.readLine().split("\\s+").map(_.toInt)
    val map = Array.ofDim[Char](h, w)

    for (i <- 0 until h) {
      map(i) = in.readLine().toCharArray
    }

    val dp = Array.ofDim[Int](h, w)

    for {
      y <- 0 until h
      x <- 0 until w
    } {
      if (map(y)(x) == '.') {
        if (x == 0 && y > 0) {
          dp(y)(x) = dp(y - 1)(x)
        } else if (y == 0 && x > 0) {
          dp(y)(x) = dp(y)(x - 1)
        } else if (x > 0 && y > 0) {
          dp(y)(x) = Math.min(dp(y - 1)(x), dp(y)(x - 1))
        }
      } else {
        if (x == 0 && y == 0) {
          dp(y)(x) = 1
        } else if (x == 0 && y > 0) {
          if (map(y - 1)(x) == '#') {
            dp(y)(x) = dp(y - 1)(x)
          } else {
            dp(y)(x) = dp(y - 1)(x) + 1
          }
        } else if (y == 0 && x > 0) {
          if (map(y)(x - 1) == '#') {
            dp(y)(x) = dp(y)(x - 1)
          } else {
            dp(y)(x) = dp(y)(x - 1) + 1
          }
        } else {
          dp(y)(x) = Math.min(dp(y - 1)(x) + {
            if (map(y - 1)(x) == '#') {
              0
            } else {
              1
            }
          }, dp(y)(x - 1) + {
            if (map(y)(x - 1) == '#') {
              0
            } else {
              1
            }
          })
        }
      }
    }

    out.println(dp(h - 1)(w - 1))

    out.flush()
  }
}
