#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <cstdio>
#include <string>
#include <vector>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <iostream>
#include <iomanip>
#include <algorithm>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(bool x) {cerr << (x ? "true" : "false");}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}

template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";}
template <typename T, typename... V>void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef HOME
#warning CHECK int:ll::INT_MAX:LLONG_MAX
#define maxn 20
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define maxn 2000006
#define debug(x...)
#endif

#define ff first
#define endl '\n'
#define ss second
#define inf 0x3f3f3f3f
#define MOD 1000000007
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
struct _ { ios_base::Init i; _() { cin.sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

int dx[] = { -1, 0, 1, 0, -1, -1, 1, 1};
int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};


int main() {

	int h, w; cin >> h >> w;
	vector<string> v(h + 1); for (int i = 1; i <= h; i++) cin >> v[i], v[i] = "." + v[i];
	vector<vector<int>> dp(h + 1, vector < int>(w + 1, 0));

	dp[1][1] = (v[1][1] == '#');
	for (int j = 2; j <= w; j++) {
		if (v[1][j] == '.' and v[1][j - 1] == '.') dp[1][j] = dp[1][j - 1];
		else if (v[1][j] == '.' and v[1][j - 1] == '#') dp[1][j] = dp[1][j - 1];
		else if (v[1][j] == '#' and v[1][j - 1] == '.') dp[1][j] = 1 + dp[1][j - 1];
		else if (v[1][j] == '#' and v[1][j - 1] == '#') dp[1][j] = dp[1][j - 1];
	}

	for (int i = 2; i <= h; i++) {
		if (v[i][1] == '.' and v[i - 1][1] == '.') dp[i][1] = dp[i - 1][1];
		else if (v[i][1] == '.' and v[i - 1][1] == '#') dp[i][1] = dp[i - 1][1];
		else if (v[i][1] == '#' and v[i - 1][1] == '.') dp[i][1] = 1 + dp[i - 1][1];
		else if (v[i][1] == '#' and v[i - 1][1] == '#') dp[i][1] = dp[i - 1][1];
	}

	for (int i = 2; i <= h; i++) {
		for (int j = 2; j <= w; j++) {
			if (v[i][j] == '.') {
				if (v[i - 1][j] == '.' and v[i][j - 1] == '.') dp[i][j] = min(dp[i - 1][j], dp[i][j - 1]);
				else if (v[i - 1][j] == '.' and v[i][j - 1] == '#') dp[i][j] = min(dp[i - 1][j], dp[i][j - 1]);
				else if (v[i - 1][j] == '#' and v[i][j - 1] == '.') dp[i][j] = min(dp[i - 1][j], dp[i][j - 1]);
				else if (v[i - 1][j] == '#' and v[i][j - 1] == '#') dp[i][j] = min(dp[i - 1][j], dp[i][j - 1]);
			}
			else {
				if (v[i - 1][j] == '.' and v[i][j - 1] == '.') dp[i][j] = min(1 + dp[i - 1][j], 1 + dp[i][j - 1]);
				else if (v[i - 1][j] == '.' and v[i][j - 1] == '#') dp[i][j] = min(1 + dp[i - 1][j], dp[i][j - 1]);
				else if (v[i - 1][j] == '#' and v[i][j - 1] == '.') dp[i][j] = min(dp[i - 1][j], 1 + dp[i][j - 1] );
				else if (v[i - 1][j] == '#' and v[i][j - 1] == '#') dp[i][j] = min(dp[i - 1][j], dp[i][j - 1]);
			}
		}
	}
	debug(dp);
	cout << dp[h][w];


	return 0;
}

Measured memory_bytes: 384