from sys import stdin def main(): input = lambda: stdin.readline()[:-1] H, W = map(int, input().split()) A = stdin.read().splitlines() grid = [[0] * W for _ in [0] * H] for i in range(1, W): if A[0][i] == '.': grid[0][i] = grid[0][i-1] + 1 else: grid[0][i] = (grid[0][i-1] + 1) * 2 for i in range(1, H): if A[i][0] == '.': grid[i][0] = grid[i-1][0] + 1 else: grid[i][0] = (grid[i-1][0] + 1) * 2 for i in range(1, H): for j in range(1, W): if A[i][j] == '.': grid[i][j] = min(grid[i][j-1] + 1, grid[i-1][j] + 1) else: grid[i][j] = min(grid[i][j-1] + 1, grid[i-1][j] + 1) * 2 print(grid[H-1][W-1]) main()