

from collections import deque

def resolve():

    INF = 1 << 60

    H, W = list(map(int, input().split()))

    G = [eval(input()) for _ in range(H)]



    dist = [[INF] * W for _ in range(H)]

    dist[0][0] = 0 if G[0][0] == "." else 1



    q = deque()

    q.append((dist[0][0], 0, 0))

    drc = [(1, 0), (0, 1)]

    while q:

        cost, y, x = q.popleft()

        for dy, dx in drc:

            ny = y + dy

            nx = x + dx

            if y + dy >= H or x + dx >= W:

                continue

            nx_cost = cost if G[y][x] == G[ny][nx] else cost + 1

            if nx_cost < dist[ny][nx]:

                dist[ny][nx] = nx_cost

                q.append((dist[ny][nx], ny, nx))



    ans = (dist[H - 1][W - 1] + 1) // 2

    print(ans)





if __name__ == "__main__":

    resolve()



def resolve():

    INF = 1 << 60

    H, W = list(map(int, input().split()))

    G = [eval(input()) for _ in range(H)]



    # 長方形区域を選んで、その中の通路と壁を反転する操作ができる

    # dp[ y ][ x ] := マス (y, x) に到達するまでに魔法を唱える回数の最小値



    dp = [[INF] * W for _ in range(H)]

    if G[0][0] == "#":

        dp[0][0] = 1

    else:

        dp[0][0] = 0



    # 1, (nx, ny) が通路のとき, 操作なし

    # 2, (nx, ny) か壁で、(x, y) が通路のとき, 操作する

    # 3, (nx, ny) が壁で、(x, y) も壁のとき, 2の操作が継続中



    drc = [(0, 1), (1, 0)]

    for y in range(H):

        for x in range(W):

            for dy, dx in drc:

                ny = y + dy

                nx = x + dx

                if ny >= H or nx >= W:

                    continue

                cost = 0

                if G[ny][nx] == "#" and G[y][x] == ".":

                    cost = 1

                dp[ny][nx] = min(dp[ny][nx], dp[y][x] + cost)



    print((dp[H - 1][W - 1]))





if __name__ == "__main__":

    resolve()
from collections import deque


def resolve():
    INF = 1 << 60
    H, W = list(map(int, input().split()))
    G = [eval(input()) for _ in range(H)]
    dist = [[INF] * W for _ in range(H)]
    dist[0][0] = 0 if G[0][0] == "." else 1
    q = deque()
    q.append((dist[0][0], 0, 0))
    drc = [(1, 0), (0, 1)]
    while q:
        cost, y, x = q.popleft()
        for dy, dx in drc:
            ny = y + dy
            nx = x + dx
            if y + dy >= H or x + dx >= W:
                continue
            nx_cost = cost if G[y][x] == G[ny][nx] else cost + 1
            if nx_cost < dist[ny][nx]:
                dist[ny][nx] = nx_cost
                q.append((dist[ny][nx], ny, nx))
    ans = (dist[H - 1][W - 1] + 1) // 2
    print(ans)


if __name__ == "__main__":
    resolve()

def resolve():
    INF = 1 << 60
    H, W = list(map(int, input().split()))
    G = [eval(input()) for _ in range(H)]
    # 長方形区域を選んで、その中の通路と壁を反転する操作ができる
    # dp[ y ][ x ] := マス (y, x) に到達するまでに魔法を唱える回数の最小値
    dp = [[INF] * W for _ in range(H)]
    if G[0][0] == "#":
        dp[0][0] = 1
    else:
        dp[0][0] = 0
    # 1, (nx, ny) が通路のとき, 操作なし
    # 2, (nx, ny) か壁で、(x, y) が通路のとき, 操作する
    # 3, (nx, ny) が壁で、(x, y) も壁のとき, 2の操作が継続中
    drc = [(0, 1), (1, 0)]
    for y in range(H):
        for x in range(W):
            for dy, dx in drc:
                ny = y + dy
                nx = x + dx
                if ny >= H or nx >= W:
                    continue
                cost = 0
                if G[ny][nx] == "#" and G[y][x] == ".":
                    cost = 1
                dp[ny][nx] = min(dp[ny][nx], dp[y][x] + cost)
    print((dp[H - 1][W - 1]))


if __name__ == "__main__":
    resolve()

-from collections import deque - - -    dist = [[INF] * W for _ in range(H)] -    dist[0][0] = 0 if G[0][0] == "." else 1 -    q = deque() -    q.append((dist[0][0], 0, 0)) -    drc = [(1, 0), (0, 1)] -    while q: -        cost, y, x = q.popleft() -        for dy, dx in drc: -            ny = y + dy -            nx = x + dx -            if y + dy >= H or x + dx >= W: -                continue -            nx_cost = cost if G[y][x] == G[ny][nx] else cost + 1 -            if nx_cost < dist[ny][nx]: -                dist[ny][nx] = nx_cost -                q.append((dist[ny][nx], ny, nx)) -    ans = (dist[H - 1][W - 1] + 1) // 2 -    print(ans) +    # 長方形区域を選んで、その中の通路と壁を反転する操作ができる +    # dp[ y ][ x ] := マス (y, x) に到達するまでに魔法を唱える回数の最小値 +    dp = [[INF] * W for _ in range(H)] +    if G[0][0] == "#": +        dp[0][0] = 1 +    else: +        dp[0][0] = 0 +    # 1, (nx, ny) が通路のとき, 操作なし +    # 2, (nx, ny) か壁で、(x, y) が通路のとき, 操作する +    # 3, (nx, ny) が壁で、(x, y) も壁のとき, 2の操作が継続中 +    drc = [(0, 1), (1, 0)] +    for y in range(H): +        for x in range(W): +            for dy, dx in drc: +                ny = y + dy +                nx = x + dx +                if ny >= H or nx >= W: +                    continue +                cost = 0 +                if G[ny][nx] == "#" and G[y][x] == ".": +                    cost = 1 +                dp[ny][nx] = min(dp[ny][nx], dp[y][x] + cost) +    print((dp[H - 1][W - 1]))