//Utkarsh.25dec
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
using namespace std;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=500023;
// bool vis[N];
vector <int> adj[N];
void solve()
{
    ll h,w;
    cin>>h>>w;
    char board[h+1][w+1];
    for(int i=1;i<=h;i++)
    {
        for(int j=1;j<=w;j++)
            cin>>board[i][j];
    }
    pair <ll,ll> start=mp(1,1);
    set <tuple<ll,ll,ll>> q;
    if(board[start.first][start.second]=='.')
        q.insert(make_tuple((ll)0,start.first,start.second));
    else
        q.insert(make_tuple((ll)1,start.first,start.second));
    map <pair<ll,ll>,ll> vis;
    map <pair<ll,ll>,ll> dist;
    if(board[start.first][start.second]=='.')
        dist[mp(1,1)]=0;
    else
        dist[mp(1,1)]=1;
    pair <ll,ll> dir[2]={{0,1},{1,0}};
    for(int i=1;i<=h;i++)
    {
        for(int j=1;j<=w;j++)
        {
            if(i==1 && j==1)
                continue;
            dist[mp(i,j)]=INT_MAX;
        }
    }
    while(!q.empty())
    {
        auto t=(*q.begin());
        pair <ll,ll> curr=mp(get<1>(t),get<2>(t));
        // cout<<curr.first<<' '<<curr.second<<'\n';
        q.erase(t);
        if(dist[curr]!=(get<0>(t)))
            continue;
        // cout<<curr.first<<' '<<curr.second<<'\n';
        for(int i=0;i<2;i++)
        {
            pair <ll,ll> next=mp(curr.first+dir[i].first,curr.second+dir[i].second);
            // cout<<next.first<<' '<<next.second<<'\n';
            if(next.first>h)
                continue;
            if(next.second>w)
                continue;
            // if(vis[next])
            //     continue;
            // vis[next]=1;
            if(board[next.first][next.second]=='.')
            {
                if(dist[next]>(dist[curr]))
                {
                    dist[next]=dist[curr];
                    q.insert(make_tuple(dist[next],next.first,next.second));
                }
            }
            else
            {
                if(board[curr.first][curr.second]=='#')
                {
                    if(dist[next]>(dist[curr]))
                    {
                        dist[next]=dist[curr];
                        q.insert(make_tuple(dist[next],next.first,next.second));
                    }
                }
                else
                {
                    if(dist[next]>(dist[curr]+1))
                    {
                        dist[next]=dist[curr]+1;
                        q.insert(make_tuple(dist[next],next.first,next.second));
                    }
                }
            }
        }
    }
    // cout<<dist[mp(1,1)]<<'\n';
    cout<<dist[mp(h,w)];
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    //cin>>T;
    int t=0;
    while(t++<T)
    {
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}


Measured memory_bytes: 12672