#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000, boost::int128_type>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }
template<class T> inline bool isSosuu(const T& n) { if (n == T(1)) { return false; } for (T i = 2; i*i <= n; ++i) { if (n % i == 0) { return false; } } return true; }
template<class T> vector<vector<T>> split (const vector<T>& S, T delim) { vector<vector<T>> ret{}; vector<T> buff{}; for (auto c : S) { if (c == delim) { if (!buff.empty()) ret.push_back(buff); buff.clear(); } else { buff.push_back(c); } } if (!buff.empty()) ret.push_back(buff); return ret; }

struct Tmp
{
public:
  int H, W;
  vector<vector<int>> table;
  vector<vector<pair<int, int>>> dp;
  Tmp(int H, int W)
    : H(H)
    , W(W)
    , table(H+1, vector<int>(W+1, 0))
    , dp(H+1, vector<pair<int, int>>(W+1, {0, 0}))
  {}

  void pre() {
    for (int h = 1; h <= H; ++h) {
      for (int w = 1; w <= W; ++w) {
        auto r0 = dp[h-1][w];
        auto r1 = dp[h][w-1];

        auto p1 = r0.second && r1.second;
        auto p2 = r0.second || r1.second;
        auto p3 = table[h][w];

        auto& r = dp[h][w];
        if (h > 1 && w > 1) {
          if (p1) {
            // 上も左も黒
            if (p3) {
              // 自分も黒
              r.first = std::min(r0.first, r1.first);
              r.second = 1;
            } else {
              // 自分は白
              r.first = std::min(r0.first, r1.first);
              r.second = 0;
            }
          } else if (p2) {
            // 上or左が黒
            if (r0.second) {
              // 上が黒, 左は白
              if (p3) {
                // 自分も黒
                r.first = std::min(r0.first, r1.first+1);
                r.second = 1;
              } else {
                // 自分は白
                r.first = std::min(r0.first, r1.first);
                r.second = 0;
              }
            }
            if (r1.second) {
              // 上が白, 左は黒
              if (p3) {
                // 自分も黒
                r.first = std::min(r0.first+1, r1.first);
                r.second = 1;
              } else {
                // 自分は白
                r.first = std::min(r0.first, r1.first);
                r.second = 0;
              }
            }
          } else {
            // 上も左も白
            if (p3) {
              // 自分は黒
              r.first = std::min(r0.first, r1.first) + 1;
              r.second = 1;
            } else {
              // 自分は白
              r.first = std::min(r0.first, r1.first);
              r.second = 0;
            }
          }
        } else if (h > 1) {
          if (r0.second) {
            // 上は黒
            if (p3) {
              // 自分も黒
              r.first = r0.first;
              r.second = 1;
            } else {
              // 自分は白
              r.first = r0.first;
              r.second = 0;
            }
          } else {
            // 上は白
            r.first = r0.first + p3;
            r.second = p3;
          }
        } else if (w > 1) {
          if (r1.second) {
            r.first = r1.first;
            r.second = p3;
          } else {
            r.first = r1.first + p3;
            r.second = p3;
          }
        } else {
          r.first = p3;
          r.second = p3;
        }
      }
    }
  }
};


void solve(void)
{
  int H, W; cin >> H >> W;
  Tmp t(H, W);
  for (int h = 1; h <= H; ++h) {
    for (int w = 1; w <= W; ++w) {
      char c; cin >> c;
      if (c == '#') {
        t.table[h][w] = 1;
      }
    }
  }
  t.pre();
  auto ans = t.dp[H][W].first;
  cout << ans << CRLF;
  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


Measured memory_bytes: 384