#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,m,f[1005][1005];
char s[1005][1005];
int main()
{
	memset(f,0x3f,sizeof(f));
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		scanf("%s",s[i]+1);
	f[1][1]=0;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
		{
			if(i>1) f[i][j]=min(f[i][j],f[i-1][j]+(s[i][j]!=s[i-1][j]));
			if(j>1) f[i][j]=min(f[i][j],f[i][j-1]+(s[i][j]!=s[i][j-1]));
		}
	int ans=(s[1][1]=='#')+(s[n][m]=='#')+f[n][m];
	printf("%d",ans/2);
	return 0;
} 