#include<bits/stdc++.h>
using namespace std;
const int N=105;
char s[N][N];
int dp[N][N],n,m,a[N][N];
void chmin(int &a,int b){if(a>b)a=b;}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		scanf("%s",s[i]+1);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			a[i][j]=a[i-1][j]+a[i][j-1]-a[i-1][j-1]+(s[i][j]=='.');
	memset(dp,0x3f,sizeof(dp));
	dp[0][1]=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			chmin(dp[i][j],dp[i-1][j]+(s[i][j]=='#'));
			chmin(dp[i][j],dp[i][j-1]+(s[i][j]=='#'));
			for(int k=1;k<=i;k++)
				for(int l=1;l<=j;l++)
					if(a[i][j]-a[i][l-1]-a[k-1][j]+a[k-1][l-1]==0)
						chmin(dp[i][j],dp[k][l]);
		}
	}
	printf("%d\n",dp[n][m]);
	return 0;
}