h,*s=open(0)

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

dp=[[9e9]*w for _ in s]

dp[0][0]=s[0][0]<'.'

for i in range(h*w):

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

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

    if y<h and x<w:dp[y][x]=min(dp[y][x],dp[i][j]+(s[i][j]=='.'>s[y][x]))

print((dp[-1][-1]))
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()
h, *s = open(0)
h, w = list(map(int, h.split()))
dp = [[9e9] * w for _ in s]
dp[0][0] = s[0][0] < "."
for i in range(h * w):
    i, j = i // w, i % w
    for y, x in ((i + 1, j), (i, j + 1)):
        if y < h and x < w:
            dp[y][x] = min(dp[y][x], dp[i][j] + (s[i][j] == "." > s[y][x]))
print((dp[-1][-1]))

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()

-h, *s = open(0) -h, w = list(map(int, h.split())) -dp = [[9e9] * w for _ in s] -dp[0][0] = s[0][0] < "." -for i in range(h * w): -    i, j = i // w, i % w -    for y, x in ((i + 1, j), (i, j + 1)): -        if y < h and x < w: -            dp[y][x] = min(dp[y][x], dp[i][j] + (s[i][j] == "." > s[y][x])) -print((dp[-1][-1])) +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()