#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<ll, ll> pair_t;
using Graph = vector<vector<ll>>;

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 3.1415926535897932;
const ll INF = 1 << 29;
/****** define constant end ********/

/****** define variable start ******/
ll h, w;
/******* define variable end *******/
ll solve()
{
    cin >> h >> w;
    vector<string> tmp(h + 1);
    vector<vector<string>> s(h + 1, vector<string>(w + 1));
    REP(i, h)
    {
        cin >> tmp[i];
        REP(j, w)
        {
            s[i][j] = tmp[i].substr(j, 1);
        }
    }
    vector<vector<ll>> dp(h + 1, vector<ll>(w + 1));
    if (s[0][0] == "#")
    {
        dp[0][0] = 1;
    }
    else
    {
        dp[0][0] = 0;
    }
    REP(i, h)
    {
        REP(j, w)
        {
            if (i > 0 && j > 0)
            {
                bool up_w;
                if (s[i - 1][j] == ".")
                {
                    up_w = true;
                }
                else
                {
                    up_w = false;
                }
                bool left_w;
                if (s[i][j - 1] == ".")
                {
                    left_w = true;
                }
                else
                {
                    left_w = false;
                }
                if (up_w == true && left_w == true)
                {
                    if (s[i][j] == ".")
                    {
                        dp[i][j] = min(dp[i - 1][j], dp[i][j - 1]);
                    }
                    else
                    {
                        dp[i][j] = min(dp[i - 1][j], dp[i][j - 1]) + 1;
                    }
                }
                else if (up_w == true && left_w == false)
                {
                    if (s[i][j] == ".")
                    {
                        dp[i][j] = min(dp[i - 1][j], dp[i][j - 1]);
                    }
                    else
                    {
                        ll from_up = dp[i - 1][j] + 1;
                        ll from_left = dp[i][j - 1];
                        if (from_up < from_left)
                        {
                            dp[i][j] = from_up;
                        }
                        else
                        {
                            dp[i][j] = from_left;
                        }
                    }
                }
                else if (up_w == false && left_w == true)
                {
                    if (s[i][j] == ".")
                    {
                        dp[i][j] = min(dp[i - 1][j], dp[i][j - 1]);
                    }
                    else
                    {
                        ll from_up = dp[i - 1][j];
                        ll from_left = dp[i][j - 1] + 1;
                        if (from_up < from_left)
                        {
                            dp[i][j] = from_up;
                        }
                        else
                        {
                            dp[i][j] = from_left;
                        }
                    }
                }
                else
                {
                    dp[i][j] = min(dp[i - 1][j], dp[i][j - 1]);
                }
            }
            else if (i == 0 && j == 0)
            {
                continue;
            }
            else if (i == 0)
            {
                if (s[i][j] == "#")
                {
                    if (s[i][j - 1] == "#")
                    {
                        dp[i][j] = dp[i][j - 1];
                    }
                    else
                    {
                        dp[i][j] = dp[i][j - 1] + 1;
                    }
                }
                else
                {
                    dp[i][j] = dp[i][j - 1];
                }
            }
            else if (j == 0)
            {
                if (s[i][j] == "#")
                {
                    if (s[i - 1][j] == "#")
                    {
                        dp[i][j] = dp[i - 1][j];
                    }
                    else
                    {
                        dp[i][j] = dp[i - 1][j] + 1;
                    }
                }
                else
                {
                    dp[i][j] = dp[i - 1][j];
                }
            }
        }
    }
    cout << dp[h - 1][w - 1] << endl;

    return 0;
}
int main()
{
    //clock_t start = clock();
    cout << std::fixed << std::setprecision(10);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll end_solve = solve();
    /*
    clock_t end = clock();
    const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
    printf("time %lf[ms]\n", time);
    */

    return (int)end_solve;
}


Measured memory_bytes: 896