#include<bits/stdc++.h>
#define maxn 105
using namespace std;
string s[maxn];
int dp[maxn][maxn];
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,m;
	cin >> n >> m;
	for(int i=0;i<n;i++)
		cin >> s[i];
	dp[0][0] = 1;
	for(int i=0;i<n;i++)
		for(int j=0;j<m;j++)
			if(i != 0 || j != 0) {
				dp[i][j] = -1;
				if(i > 0)	dp[i][j] = dp[i-1][j] + (s[i][j] != s[i-1][j] ? 1 : 0);
				if(j > 0) {
					int now = dp[i][j-1] + (s[i][j] != s[i][j-1] ? 1 : 0);
					if(dp[i][j] == -1 || dp[i][j] > now)
						dp[i][j] = now;
				}
			}
	cout << (s[0][0] == '#' || s[n-1][m-1] == '#' ? 1 : 0) + (dp[n-1][m-1] - 1) / 2 << endl;
	return 0;
}
