#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20);
#define YES cout << "Yes" << endl;
#define NO cout << "No" << endl;
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

/*int h,w;

void dfs(int x,int y,vvc &data,vvi &cost,int d=0,char state='.'){
    if(x >= h || y >= w) return;
    if(cost.at(x).at(y) < d) return;
    if(data.at(x).at(y) == '#' && state=='.') d++;
    cost.at(x).at(y) = min(cost.at(x).at(y),d);

    dfs(x+1,y,data,cost,d,data.at(x).at(y));
    dfs(x,y+1,data,cost,d,data.at(x).at(y));
}

int main(){
    
    cin >> h >> w;
    vvc data(h,vector<char>(w));
    rep(i,h){
        rep(j,w){
            cin >> data.at(i).at(j);
        }
    }
    vvi cost(h,vi(w,1e9));
    dfs(0,0,data,cost);
    cout << cost.at(h-1).at(w-1) << endl;
}*/

/*
int dx[2] = {1,0};
int dy[2] = {0,1}; 

struct Per{
    int x;
    int y;
    int cost;
    //char c;
};

int main(){
    int h,w;
    cin >> h >> w;
    vvc data(h,vector<char>(w));
    rep(i,h){
        rep(j,w){
            cin >> data.at(i).at(j);
        }
    }
    vvi cos(h,vi(w,1e9));
    queue<Per> que;
    struct Per d0 = {0,0,data.at(0).at(0)=='#'};
    que.push(d0);
    while(que.size()){
        struct Per d = que.front();
        int x = d.x;
        int y = d.y;
        que.pop();
        if(d.cost > cos.at(x).at(y)) continue;
        cos.at(x).at(y) = min(cos.at(x).at(y),d.cost);
        //if(d.c == '.' && data.at(x).at(y) == '#') d.cost++;
        rep(i,2){
            if(x+dx[i] >= h || y+dy[i] >= w) continue;
            int flag = (data.at(x).at(y) == '.' && data.at(x+dx[i]).at(y+dy[i]) == '#');
            if(d.cost + flag > cos.at(x+dx[i]).at(y+dy[i])) continue;
            struct Per nd = {x+dx[i],y+dy[i],d.cost + flag};
            que.push(nd);
        }
    }
    cout << cos.at(h-1).at(w-1) << endl;
}*/

int di[2] = {1,0};
int dj[2] = {0,1}; 

int main(){
    int h,w;
    cin >> h >> w;
    vvc data(h,vector<char>(w));
    rep(i,h){
        rep(j,w){
            cin >> data.at(i).at(j);
        }
    }
    vvi dist(h,vi(w,1e9));
    dist.at(0).at(0) = (data.at(0).at(0) == '#');
    deque<pair<int, int>> que;
    que.push_back({0, 0});
    while(que.size()){
        // 先頭を取る
        auto p = que.front(); que.pop_front();
        int i = p.first, j = p.second;
 
        // 4方向の遷移
        for(int k=0; k<2; k++){
            int i2 = i + di[k], j2 = j + dj[k];
            if(i2 < 0 || i2 >= h || j2 < 0 || j2 >= w) continue;
 
            // この経路での始点から遷移先までの距離。壁なら+1
            bool add = (data[i][j] == '.' && data[i2][j2] == '#');
            int d2 = dist[i][j] + add;
 
            // 暫定距離より短い経路が得られた場合は更新して、+1なら後ろに、+0なら前に付ける
            if(dist[i2][j2] > d2){
                dist[i2][j2] = d2;
                if(add){
                    que.push_back({i2, j2});
                }else{
                    que.push_front({i2, j2});
                }
            }
        }
    }
    cout << dist[h-1][w-1] << endl;
}

Measured memory_bytes: 256