/*    Author: arpitp699
    ----ARPIT PATEL----
*/
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ld long double
#define pi pair<int,int>
#define pl pair<ll,ll>
#define vi vector<int> 
#define vvi vector<vi>
#define vvl vector<vl>
#define vl vector<ll>
#define vpi vector<pi> 
#define vpl vector<pl>

#define PB emplace_back
#define MP make_pair
#define SZ(x) (ll)x.size()
#define SS second
#define FF first

#ifdef LOCAL
#define error(args...) { griding _s = #args; replace(_s.begin(), _s.end(), ',', ' '); gridinggrideam _ss(_s); igrideam_iterator<griding> _it(_ss); err(_it, args); }
#define debugVec(a) cout<<"#### = "<<#a<<endl; for(auto x:a) cout<<x<<" "; cout<<endl;
#define debug(a) cout<<"#### = "<<#a<<endl; for(auto x:a){ cout<<x.FF<<" "<<x.SS<<endl;}
#endif

#ifdef ONLINE_JUDGE
#define error(args...)
#define debugVec(a) 
#define debug(a)
#endif

#define endl "\n"
#define MOD 1000000007
#define MAX 100010

#define ALL(x) x.begin(),x.end()
#define REP(i,a,n) for(ll i=a;i<n;++i)
#define REPR(i,n,b) for(ll i=n;i>=b;i--)
#define tr(x, it) for(typeof(x.begin()) it = x.begin(); it != x.end(); it++)

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int test=1;
    // cin>>test;
    while(test--){
        int h,w; cin>>h>>w;

        vector<string> grid(h);
        REP(i,0,h){
            string str; cin>>str;
            grid[i]=str;
        } 

        vvi dp(h,vi(w,INT_MAX));
        if(grid[0][0]!='.') dp[0][0]=1;
        else
            dp[0][0]=0;

        REP(i,0,h){
            if(grid[i][0]=='#'){
                if(i!=0 and grid[i-1][0]=='#'){
                    dp[i][0]=dp[i-1][0];
                }
                else{
                    if(i!=0)
                        dp[i][0]=1+dp[i-1][0];
                }
            }
            else{
                if(i!=0)
                    dp[i][0]=dp[i-1][0];
            }
        }

        REP(i,0,w){
            if(grid[0][i]=='#'){
                if(i!=0 and grid[0][i-1]=='#'){
                    dp[0][i]=dp[0][i-1];
                }
                else{
                    if(i!=0)
                        dp[0][i]=1+dp[0][i-1];
                }
            }
            else{
                if(i!=0)
                    dp[0][i]=dp[0][i-1];
            }
        }

        REP(i,1,h){
            REP(j,1,w){
                if(grid[i][j]=='.'){
                    dp[i][j]=min(dp[i-1][j],dp[i][j-1]);
                }
                else{
                    if(grid[i-1][j]=='#'){
                        dp[i][j]=dp[i-1][j];
                    }
                    else if(grid[i-1][j]=='.'){
                        dp[i][j]=dp[i-1][j]+1;
                    }
                    if(grid[i][j-1]=='.'){
                        dp[i][j]=min(dp[i][j],dp[i][j-1]+1);
                    }
                    else if(grid[i][j-1]=='#'){
                        dp[i][j]=min(dp[i][j],dp[i][j-1]);
                    }
                }
            }
        }

       /* REP(i,0,h){
            cout<<i<<"->>";
            REP(j,0,w){
                cout<<dp[i][j]<<" ";
            }
            cout<<endl;
        }*/

        cout<<dp[h-1][w-1]<<endl;
    }
}

Measured memory_bytes: 384