#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int h, w;
vint dx = {1, 0}, dy = {0, 1};

int bfs(vstr maze, vvint d) {
    int sx = 0;
    int sy = 0;
    int gx = h-1;
    int gy = w-1;
    deque<P> que;
    que.push_front(P(sx, sy));
    if (maze[sx][sy] == '.') d[sx][sy] = 0;
    else d[sx][sy] = 1;
 
    while (que.size()) {
        P p = que.front();
        que.pop_front();
        rep(i, 2) {
            int nx = p.fi + dx[i], ny = p.se + dy[i];
            if (0 <= nx && nx < h && 0 <= ny && ny < w && d[nx][ny] == INF) {
                
                if (maze[p.fi][p.se] == '.' && maze[nx][ny] == '#') {
                    que.push_front(P(nx, ny));
                    d[nx][ny] = min(d[nx][ny], d[p.fi][p.se] + 1);
                } else {
                    que.push_front(P(nx, ny));
                    d[nx][ny] = min(d[nx][ny], d[p.fi][p.se]);
                }
            }
        }
    }
    rep(i, h) show_ary(d[i]);
    return d[gx][gy];
}

int main() {
    cin >> h >> w;
    vstr s(h);
    rep(i, h) cin >> s[i];

    vvint d(h, vint(w, INF));
    if (s[0][0] == '.') d[0][0] = 0;
    else d[0][0] = 1;
    
    rep(i, h) {
        rep(j, w) {
            if (i == 0 && j == 0) continue;
            int add;
            if (i > 0) {
                if (s[i][j] == '#' && s[i-1][j] == '.') add = 1;
                else add = 0;
                d[i][j] = min(d[i-1][j]+add, d[i][j]);
            }
            if (j > 0) {
                if (s[i][j] == '#' && s[i][j-1] == '.') add = 1;
                else add = 0;
                d[i][j] = min(d[i][j-1]+add, d[i][j]);
            }
        }
    }
    // rep(i, h) show_ary(d[i]);

    int ans = d[h-1][w-1];

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256