// g++ -std=c++14

/*

Today might be the chance to grasp the chance to let your talent bloom.
May be tomorrow, the day after, or next year...
May be even when you are 30. I'm not sure if physique has anything to do with it
but if you think that it will never come, it probably never will.

- Tooru Oikawa.

*/


#include<bits/stdc++.h>

typedef long long ll;
typedef long double lld;
using namespace std;

#define endl "\n"
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define __ freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define all(c) c.begin(),c.end()
#define pii pair<int, int>
#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)
template<typename S, typename T>
ostream& operator<<(ostream& out,pair<S,T> const& p){out<<'('<<p.fi<<", "<<p.se<<')';return out;}

template<typename T>
ostream& operator<<(ostream& out,vector<T> const& v){
ll l=v.size();for(ll i=0;i<l-1;i++)out<<v[i]<<' ';if(l>0)out<<v[l-1];return out;}

template <typename T>
ostream &operator<<(ostream &out, set<T> const &v) {
    for (auto i = v.begin(); i != v.end(); i++)
        out << (*i) << ' ';
    return out;
}
template <typename T, typename V>
ostream &operator<<(ostream &out, map<T, V> const &v) {
    for (auto i = v.begin(); i != v.end(); i++)
        out << "\n" << (i->first) <<  ":"  << (i->second);
    return out;
}

template<typename T>
void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}

template<typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cout.write(names, comma-names)<<" : "<<arg1<<" | ";trace(comma+1,args...);}

const int N = 102;
string arr[N];
int n, m;
int enc(int i, int j) {
    return (i * m + j);
}

pii dec(int x) {
    int j = x % m;
    int i = x / m;
    return {i, j};
}

int mx[] = {0, 1};
int my[] = {1, 0};

const int INF = 1000000000;


int valid(int x, int y) {
    return (x >= 0 && x < n && y >= 0 && y < m);
}


void dijkstra(int s) {
    vector<int> d(N * N, INF);
    d[s] = (arr[0][0] == '#');
    priority_queue<pii, vector<pii>, greater<pii>> q;
    q.push({(arr[0][0] == '#'), s});
    while (!q.empty()) {
        int v = q.top().second;
        int d_v = q.top().first;
        q.pop();
        if (d_v != d[v])
            continue;

        auto p = dec(v);
        // tr(v, d_v, p);

        for (int i = 0; i < 2; i++) {
            int x = p.fi + mx[i];
            int y = p.se + my[i];
            if (valid(x, y)) {
                int cost = (arr[p.fi][p.se] == '.') && (arr[x][y] == '#');
                // tr(x, y, cost, enc(x, y));
                if (d[v] + cost < d[enc(x, y)]) {
                    d[enc(x, y)] = d[v] + cost;
                    q.push({ d[enc(x, y)], enc(x, y)});
                }
            }
        }
    }
    cout << d[enc(n - 1, m - 1)] << endl;
}

int solve() {
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
    }
    
    dijkstra(enc(0, 0));
    return 0;
}

int32_t main(){ _
    int t;
    // cin >> t;
    t = 1;
    while (t--) solve();
}


Measured memory_bytes: 384