def main():

  import sys

  input=sys.stdin.buffer.readline

  h,w=list(map(int,input().split()))

  s=[c<46and 1or 0for _ in range(h)for c in input()[:w]]

  dp=[10**9]*h*w

  dp[0]=s[0]

  for i in range(h*w):

    j,k=i//w,i%w

    for y,x in((j+1,k),(j,k+1)):

      if y<h and x<w:

        z=y*w+x

        t=dp[i]+(s[i]^s[z])

        if dp[z]>t:dp[z]=t

  print((dp[-1]+1>>1))

main()
def main():

  import sys

  input=sys.stdin.buffer.readline

  h,w=list(map(int,input().split()))

  s=[c//8for _ in range(h)for c in input()[:w]]

  dp=[10**9]*h*w

  dp[0]=5-s[0]

  for i in range(h):

    for j in range(w):

      k=i*w+j

      if j+1<w:

        t=dp[k]+(s[k]^s[k+1])

        if dp[k+1]>t:dp[k+1]=t

      if i+1<h:

        t=dp[k]+(s[k]^s[k+w])

        if dp[k+w]>t:dp[k+w]=t

  print((dp[-1]+1>>1))

main()
def main():
    import sys

    input = sys.stdin.buffer.readline
    h, w = list(map(int, input().split()))
    s = [c < 46 and 1 or 0 for _ in range(h) for c in input()[:w]]
    dp = [10**9] * h * w
    dp[0] = s[0]
    for i in range(h * w):
        j, k = i // w, i % w
        for y, x in ((j + 1, k), (j, k + 1)):
            if y < h and x < w:
                z = y * w + x
                t = dp[i] + (s[i] ^ s[z])
                if dp[z] > t:
                    dp[z] = t
    print((dp[-1] + 1 >> 1))


main()

def main():
    import sys

    input = sys.stdin.buffer.readline
    h, w = list(map(int, input().split()))
    s = [c // 8 for _ in range(h) for c in input()[:w]]
    dp = [10**9] * h * w
    dp[0] = 5 - s[0]
    for i in range(h):
        for j in range(w):
            k = i * w + j
            if j + 1 < w:
                t = dp[k] + (s[k] ^ s[k + 1])
                if dp[k + 1] > t:
                    dp[k + 1] = t
            if i + 1 < h:
                t = dp[k] + (s[k] ^ s[k + w])
                if dp[k + w] > t:
                    dp[k + w] = t
    print((dp[-1] + 1 >> 1))


main()

-    s = [c < 46 and 1 or 0 for _ in range(h) for c in input()[:w]] +    s = [c // 8 for _ in range(h) for c in input()[:w]] -    dp[0] = s[0] -    for i in range(h * w): -        j, k = i // w, i % w -        for y, x in ((j + 1, k), (j, k + 1)): -            if y < h and x < w: -                z = y * w + x -                t = dp[i] + (s[i] ^ s[z]) -                if dp[z] > t: -                    dp[z] = t +    dp[0] = 5 - s[0] +    for i in range(h): +        for j in range(w): +            k = i * w + j +            if j + 1 < w: +                t = dp[k] + (s[k] ^ s[k + 1]) +                if dp[k + 1] > t: +                    dp[k + 1] = t +            if i + 1 < h: +                t = dp[k] + (s[k] ^ s[k + w]) +                if dp[k + w] > t: +                    dp[k + w] = t