#include<bits/stdc++.h>
using namespace std;
int main() {
	int n,m;
	vector<string>grid;
	vector<vector<int> >dp;
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>m;
	grid.resize(n);
	dp.resize(n,vector<int>(m,0x3f3f3f3f));
	for(int i=0;i<n;i++) cin>>grid[i];
	for(int i=0;i<n;i++)
		for(int j=0;j<m;j++)
			if(i==0&&j==0) dp[i][j]=grid[0][0]=='#';
			else {
				if(i>0) dp[i][j]=min(dp[i][j],dp[i-1][j]+(grid[i-1][j]=='.'&&grid[i][j]=='#'));
				if(j>0) dp[i][j]=min(dp[i][j],dp[i][j-1]+(grid[i][j-1]=='.'&&grid[i][j]=='#'));
			}
	cout<<dp[n-1][m-1]<<"\n";
	return 0;
}