### BUGGY CODE ###

import queue
def main():
    h, w = map(int, input().split())
    s = [list(input().rstrip()) for _ in range(h)]
#    q = queue.Queue()
    a = []
    t = [[10**9]*w for _ in range(h)]
    if s[h-1][w-1] == "#":
        t[h-1][w-1] = 1
#        q.put([h-1, w-1])
    else:
        t[h-1][w-1] = 0
    a.append([h-1, w-1])
    while 0 < len(a):
        y, x = a[len(a)-1][0], a[len(a)-1][1]
        if y < h-1 and x < w-1:
            py = t[y+1][x]
            if s[y][x] == "#" and s[y+1][x] == ".":
                py += 1
            px = t[y][x+1]
            if s[y][x] == "#" and s[y][x+1] == ".":
                px += 1
            t[y][x] = min(py, px)
        elif y == h-1 and x < w-1:
            px = t[y][x+1]
            if s[y][x] == "#" and s[y][x+1] == ".":
                px += 1
            t[y][x] = px
        elif x == w-1 and y < h-1:
            py = t[y+1][x]
            if s[y][x] == "#" and s[y+1][x] == ".":
                py += 1
            t[y][x] = py
        a.pop(-1)
        if 0 < y:
            a.append([y-1, x])
        if 0 < x:
            a.append([y, x-1])

#        q.put([h-1, w-1])
#    while not q.empty():
#        y, x = q.get()
#        print(y, x)
#        if 0 < y and 0 < x:
#            if s[y][x] == "#":
#                q.put([y-1, x])
#                q.put([y, x-1])
#            else:
#                if s[y-1][x] == "#":
#                    t[y-1][x] = t[y][x] + 1
#                else:
#                    t[y-1][x] = t[y][x]
#                if s[y][x-1] == "#":
#                    t[y][x-1] = t[y][x] + 1
#                else:
#                    t[y][x-1] = t[y][x]
#            q.put([y-1, x])
#            q.put([y, x-1])
#        elif y == 0 and 0 < x:
#            if s[y][x] == "#":
#                q.put([y, x-1])
#            else:
#                if s[y][x-1] == "#":
#                    t[y][x-1] = t[y][x] + 1
#                else:
#                    t[y][x-1] = t[y][x]
#            q.put([y, x-1])
#        elif x == 0 and 0 < y:
#            if s[y][x] == "#":
#                q.put([y-1, x])
#            else:
#                if s[y-1][x] == "#":
#                    t[y-1][x] = t[y][x] + 1
#                else:
#                    t[y-1][x] = t[y][x]
#            q.put([y-1, x])
    print(t[0][0])

if __name__ == "__main__":
    main()

### FIXED CODE ###

import queue
def main():
    h, w = map(int, input().split())
    s = [list(input().rstrip()) for _ in range(h)]
    q = queue.Queue()
    t = [[10**9]*w for _ in range(h)]
    f = [[True]*w for _ in range(h)]
    if s[h-1][w-1] == "#":
        t[h-1][w-1] = 1
    else:
        t[h-1][w-1] = 0
    q.put([h-1, w-1])
    while not q.empty():
        y, x = q.get()
        if y < h-1 and x < w-1:
            py = t[y+1][x]
            if s[y][x] == "#" and s[y+1][x] == ".":
                py += 1
            px = t[y][x+1]
            if s[y][x] == "#" and s[y][x+1] == ".":
                px += 1
            t[y][x] = min(py, px)
        elif y < h-1 and x == w-1:
            py = t[y+1][x]
            if s[y][x] == "#" and s[y+1][x] == ".":
                py += 1
            t[y][x] = py
        elif y == h-1 and x < w-1:
            px = t[y][x+1]
            if s[y][x] == "#" and s[y][x+1] == ".":
                px += 1
            t[y][x] = px
        if 0 < y:
            if f[y-1][x]:
                f[y-1][x] = False
                q.put([y-1, x])
        if 0 < x:
            if f[y][x-1]:
                f[y][x-1] = False
                q.put([y, x-1])
    print(t[0][0])

if __name__ == "__main__":
    main()