#include "vector"
#include "set"
#include "map"
#include "unordered_map"
#include "string"
#include "iostream"
#include "algorithm"
#include "queue"

using namespace std;

#define ll long long
#define INF 2e9
#define MOD 1000000007

typedef vector<int> vi;
typedef pair<int, int> pii;


template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    bool first = true;
    for (const auto& x : v) {
        if (!first) {
            os << " ";
        }
        first = false;
        os << x;
    }
    return os;
}

template<typename T>
istream& operator>>(istream& is, vector<T>& v) {
    for (auto& elem : v) {
        is >> elem;
    }
    return is;
}

ll pw(ll x, int n) {
    if (n == 1) {
        return x;
    }
    if (n%2 == 0) {
        return pw((x*x) % MOD, n/2);
    }
    return (pw(x, n-1) * x) % MOD;
}

ll dv(ll a, ll b) {
    return (a * pw(b, MOD - 2)) % MOD;
}

vector<ll> f;
void set_f(int n) {
    f.resize(n+1);
    f[0] = 1;
    for (int i=1; i<= n; i++) {
        f[i] = (f[i-1] * i) % MOD;
    }
}

ll c_n_k(int n, int k) {
    return dv(dv(f[n], f[k]), f[n-k]);
}

int get_min(map<int, int>& m) {
    return m.begin()->first;
}
int get_min2(map<int, int>& m) {
    auto it = m.begin();
    it++;
    return it->first;
}

int get_min(set<int>& m) {
    return *m.begin();
}

int get_max(map<int, int>& m) {
    auto it = m.end();
    it--;
    return it->first;
}
int get_max2(map<int, int>& m) {
    auto it = m.end();
    it--;
    it--;
    return it->first;
}

int get_max(set<int>& m) {
    auto it = m.end();
    it--;
    return *it;
}


//vector<vi> g;
//vi c;
//ll cc[100000][4];
//ll dfs(int x, int xc, int p, int pc) {
//    c[x] = xc;
//    for (int y : g[x]) {
//        if (y != p) {
//            int cur = 6 - xc - pc;
//            return cc[x][xc] + dfs(y, cur, x, xc);
//        }
//    }
//
//    return cc[x][xc];
//}

void solve() {
    int n, m;
    cin >> n >> m;

    vector<string> s(n);
    for (int i=0; i<n; i++) {
        cin >> s[i];
    }

    int a[100][100];
    for (int j=0; j<n; j++) {
        for (int i=0; i<m; i++) {
            if (i==0 && j==0) {
                if (s[j][i] == '.') {
                    a[j][i] = 0;
                } else {
                    a[j][i] = 1;
                }
            } else {
                a[j][i] = 1000;
                if (i>0) {
                    int c=a[j][i-1];
                    if (s[j][i-1]!=s[j][i] && s[j][i]=='#') {
                        c++;
                    }
                    a[j][i] = min(a[j][i], c);
                }
                if (j>0){
                    int c=a[j-1][i];
                    if (s[j-1][i]!=s[j][i] && s[j][i]=='#') {
                        c++;
                    }
                    a[j][i] = min(a[j][i], c);
                }
            }
        }
    }

    cout << a[n-1][m-1];
}

int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);

    if (0) {
        int tests;
        cin >> tests;
        while (tests--) {
            solve();
            cout << endl;
        }
    } else {
        solve();
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 256