#include <bits/stdc++.h>
using namespace std;
int h,w;
vector<vector<int> >dp;
vector<vector<char> >a;
int main(){
	
	cin>>h>>w;
	dp=vector<vector<int> >(h+1,vector<int>(w+1,1e9));
	a=vector<vector<char> >(h+1,vector<char>(w+1,'.'));
	
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++)cin>>a[i][j];
	}	
	
	dp[1][0]=dp[0][1]=0;
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			if(a[i][j]=='.')dp[i][j]=min(dp[i][j-1],dp[i-1][j]);
			else{
				dp[i][j]=min(dp[i][j],dp[i][j-1]+(a[i][j-1]=='.'));
				dp[i][j]=min(dp[i][j],dp[i-1][j]+(a[i-1][j]=='.'));
			}
		}
	}
	cout<<dp[h][w];
	return 0;
}
