#include<bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long long ll;
const int maxn=1e3+3;
const int inf=1e9+3;
char s[maxn][maxn];
int dp[maxn][maxn];
int n,m;

int main(){
    cin >> 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++){
        if (i==1&&j==1) {
            dp[i][j]=s[i][j]=='#';
            continue;
        }
        dp[i][j]=inf;
        if (i>1) dp[i][j]=min(dp[i][j],dp[i-1][j]+(s[i-1][j]=='.'&&s[i][j]=='#'));
        if (j>1) dp[i][j]=min(dp[i][j],dp[i][j-1]+(s[i][j-1]=='.'&&s[i][j]=='#'));
    }
    cout << dp[n][m] << endl;
}
