#include<bits/stdc++.h>

using namespace std;
#define ll long long
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define deb(x) cout<<#x<<" : "<<x<<"\n";
#define debug(x, y) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<"\n";
#define all(a) (a).begin(),(a).end()
#define bs binary_search
#define vi vector<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ld long double
#define ff first
#define ss second
#define ub upper_bound
#define lb lower_bound
#define clr fflush(stdout);
#define N 100001
#define fpr(i, a, b) for(int i=a;i<b;i++)
#define fdr(i, a, b) for(int i=a;i>b;i--)
#define repp(i, a, b, d) for(int i=a;i<b;i+=d)
#define repd(i, a, b, d) for(int i=a;i>b;i-=d)
#define LLMIN LLONG_MIN
#define LLMAX LLONG_MAX
#define mset(x, a) memset(x,a,sizeof(x));
#define nl cout<<'\n';
#define print(c) cout<<c<<'\n';
#define setp(n) cout << fixed << setprecision(n)
#define take_arr(a, n) fpr(i,0,n) cin>>a[i];
#define print_arr(a, n) for(int i=0;i<n;i++) {cout<<a[i]<<" ";} cout<<'\n';
#define sz size()

template<class T>
bool inside(T a, T b, T c) { return a <= b && b <= c; }

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,m;
    cin>>n>>m;
    char c[n+1][m+1];
    fpr(i,1,n+1)
    {
        fpr(j,1,m+1)
        {
            cin>>c[i][j];
        }
    }
    ll dp[n+1][m+1];
    fpr(i,0,n+1)
    {
        fpr(j,0,m+1)
        {
            dp[i][j]=INT_MAX;
        }
    }
    dp[0][0]=0;
    dp[0][1]=0;
    dp[1][0]=0;
    int ps[n+2][m+2];
    fpr(i,1,n+1)
    {
        fpr(j,1,m+1)
        {
            if(c[i][j]=='.')
            {
                dp[i][j]=min(dp[i-1][j],dp[i][j-1]);
            } else{
                int l=i,r=j;
                l=1,r=1;
                fpr(p,l,i+2)
                {
                    fpr(q,r,j+2)
                    {
                        ps[p][q]=0;
                    }
                }
                fdr(p,i,l-1)
                {
                    fdr(q,j,r-1)
                    {
                        if(p==i && q==j)
                        {
                            ps[p][q]=1;
                        }
                        else if(c[p][q]=='#')
                        {
                            ps[p][q]=max(ps[p+1][q],ps[p][q+1]);
                        }
                        else
                        {
                            ps[p][q]=0;
                        }
                    }
                }
                fpr(p,l,i+1)
                {
                    fpr(q,r,j+1)
                    {
                        if(c[p][q]=='#' && ps[p][q])
                        {
                            if(p==1 || c[p-1][q]=='.')
                            {
                                dp[i][j]=min(dp[i][j],dp[p-1][q]+1);
                            }
                            if(q==1 || c[p][q-1]=='.')
                            {
                                dp[i][j]=min(dp[i][j],dp[p][q-1]+1);
                            }
                        }
                    }
                }
                if(dp[i][j]>=INT_MAX)
                {
                    dp[i][j]=min(dp[i-1][j],dp[i][j-1])+1;
                }
            }
        }
    }
    print(dp[n][m])
    return 0;
}





Measured memory_bytes: 384