#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define PB push_back
#define SP << " " <<

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;

__attribute__((constructor))
void initial(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed <<setprecision(15);
}


int main(void){
	int H, W;
    cin >> H >> W;
    VVI s, x;
    rep(i,H){
        VI a, xa;
        rep(j,W){
            int b = 1;
            char c;
            cin >> c;
            if(c == '.') b = 0; 
            a.PB(b);
            xa.PB(2000);
        }
        s.PB(a);
        x.PB(xa);
    }



    int left, up;
    left = 2000;
    up = 2000;

    rep(ii,H+W-1){
        for(int jj = 0; jj <=ii; jj++){
            int i = jj;
            int j = ii-jj;
            
            if(i == 0 && j == 0){
                x[i][j] = s[i][j];
            }else{
                if(i<H){
                    if(j>=0 && j<W){
                        if(i == 0){
                            if(s[i][j] == 0){
                                up = 2000;
                                left = x[i][j-1];
                                chmin(x[i][j],up);
                                chmin(x[i][j],left);
                            }else{
                                up = 2000; 
                                if(s[i][j-1] == 0){
                                    left = x[i][j-1]+1;
                                }else{
                                    left = x[i][j-1];
                                }
                                chmin(x[i][j],up);
                                chmin(x[i][j],left);
                            }
                            
                        }else{
                            if(j == 0){
                                if(s[i][j] == 0){
                                    up = x[i-1][j];
                                    left = 2000;
                                    chmin(x[i][j],up);
                                    chmin(x[i][j],left);
                                }else{
                                    if(s[i-1][j] == 0){
                                        up = x[i-1][j] + 1;
                                    }else{
                                        up = x[i-1][j];
                                    } 
                                    left = 2000;
                                    chmin(x[i][j],up);
                                    chmin(x[i][j],left);
                                }
                            }else{
                                if(s[i][j] == 0){
                                    up = x[i-1][j];
                                    left = x[i][j-1];
                                    chmin(x[i][j],up);
                                    chmin(x[i][j],left);
                                }else{
                                    if(s[i-1][j] == 0){
                                        up = x[i-1][j] + 1;                                    
                                    }else{
                                        up = x[i-1][j];
                                    } 
                                    if(s[i][j-1] == 0){
                                        left = x[i][j-1]+1;
                                    }else{
                                        left = x[i][j-1];
                                    }
                                    chmin(x[i][j],up);
                                    chmin(x[i][j],left);
                                }
                            }
                            
                        }
                        //cout << i << j << " ";
                        //cout << up SP left << "  ";
                    }
                }else{
                    //cout << "a";
                }
            }
            
            
        }
        //cout << endl;
    }

    /*rep(i,H){
        rep(j,W){
            cout << x[i][j] << " ";
        }
        cout << endl;
    }*/

    cout << x[H-1][W-1] << endl;

    return 0;
}


Measured memory_bytes: 384