import java.util.*; public class Main{ public static void main(String[] args) throws Exception { Scanner sc=new Scanner(System.in); int h = sc.nextInt(); int w = sc.nextInt(); int[][] a = new int[h][w]; for(int i = 0;i < h;i++){ String s = sc.next(); for(int j = 0;j < w;j++){ if(s.charAt(j) == '.'){ a[i][j]=0; }else{ a[i][j]=1; } } } int[][] dp =new int[h][w]; int INM = 1145141919; for(int i = 0;i < h;i++){ for(int j = 0;j < w;j++){ dp[i][j]=INM; } } dp[0][0] = 0; for(int i = 0;i < h;i++){ for(int j = 0;j < w;j++){ if(a[i][j] == 0){ if (i > 0) { dp[i][j] = Math.min(dp[i][j], dp[i-1][j] + 1); } if (j > 0) { dp[i][j] = Math.min(dp[i][j], dp[i][j-1] + 1); } }else{ if (i > 0){ dp[i][j] = Math.min(dp[i][j], dp[i-1][j] + 1 + i + j); } if (j > 0){ dp[i][j] = Math.min(dp[i][j], dp[i][j-1] + 1 + i + j); } } } } System.out.println(dp[h - 1][w - 1]); } }