import sys input = sys.stdin.readline H, W = map(int, input().split()) a = [input()[:-1] for _ in range(H)] dp = [[10**18]*W for _ in range(H)] dp[0][0] = 0 for i in range(H): for j in range(W): if i>0: dp[i][j] = min(dp[i][j], dp[i-1][j]+(1 if a[i][j]=='.' else i+j+1)) if j>0: dp[i][j] = min(dp[i][j], dp[i][j-1]+(1 if a[i][j]=='.' else i+j+1)) print(dp[H-1][W-1])