#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
typedef long long   ll;
#define pb                push_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define clr(a,h)          memset(a, (h), sizeof(a))
#define mem(a,h)          memset(a, (h), sizeof(a))
#define fi first
#define se second
#define por(a,b) (((a%MOD) * (b%MOD))%MOD)
#define forg(i, b, e, c)    for (ll i = (ll)b; i < (ll)e; i+=c)
#define forr(i, b, e)    for (ll i = b; i < e; i++)
 
 
using namespace std;
//using namespace __gnu_pbds;
typedef double lldb;
typedef pair<ll, ll>  ii;
typedef pair<ll, ii>  iii;
typedef vector<ll>     vi;
typedef vector<vi>     vvi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const ll INF = 1e9;
const double PI = acos(-1);
#define tam 3000
#define offset 
const ll MOD= 1e9+7;



#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {

template < class c > struct rge { c b, e; };
template < class c > rge<c> range(c i, c j) { return rge<c>{i, j}; }
template < class c > auto dud(c* x) -> decltype(cerr << *x, 0);
template < class c > char dud(...);

struct debug {
    ~debug() { cerr << endl; }
    
    //     Part 1
    
    template < class c > typename \
    enable_if<sizeof dud<c>(0) != 1, debug&>::type operator<<(c i) {
        cerr << boolalpha << i;
        return * this;
    }
    
    //     Part 2
    
    template < class c > typename \
    enable_if<sizeof dud<c>(0) == 1, debug&>::type operator<<(c i) {
        return * this << range(begin(i), end(i)); 
    }
    
    //   Part 3
    
    template < class c, class b > debug & operator << (pair < b, c > d) {
        return * this << "(" << d.first << ", " << d.second << ")";
    }
    
    //   Part 4
    
    template < class c > debug & operator <<(rge<c> d) {
        *this << "[";
        for (auto it = d.b; it != d.e; ++it)
            *this << ", " + 2 * (it == d.b) << *it;
        return * this << "]";
    }
    
};
#define qwer(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
string txt[tam];
int n,m;
int dp[tam][tam][2];
int f(int y,int x,int usado)
{
    if (y==n-1 && x==m-1)
    {
        if (usado==1)
            return 0;
        if (txt[y][x]=='#')
            return 1;
        return 0;
    }
    
    if (dp[y][x][usado]!=-1)
        return dp[y][x][usado];
    int formas=1e9;
    if (usado)
    {
        if ( y+1<n)
        {
            if (txt[y+1][x]=='#')
            formas=min(formas, f(y+1,x,usado));
            else
            formas=min(formas, f(y+1,x,0));
        }
        if (x+1<m)
        {
            if (txt[y][x+1]=='#')
            formas=min(formas, f(y,x+1,usado));
            else
            formas=min(formas, f(y,x+1,0));
        }
    }
    else
    {
        if ( y+1<n)
        {
            if (txt[y+1][x]=='#')
            formas=min(formas, f(y+1,x,1)+1);
            else
            formas=min(formas, f(y+1,x,0));
        }
        if (x+1<m)
        {
            if (txt[y][x+1]=='#')
            formas=min(formas, f(y,x+1,1)+1);
            else
            formas=min(formas, f(y,x+1,0));
        }
    }
    return dp[y][x][usado]=formas;
}

int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    
    cin>>n>>m;
    forr(i,0,n)
    {
        cin>>txt[i];
    }
    memset(dp,-1,sizeof dp);
    if (txt[0][0]=='.')
    cout<<f(0,0,0)<<endl;
    else
    cout<<f(0,0,1)+1<<endl;

}
// PLUS ULTRA!
    

Measured memory_bytes: 70656