// Contest: AtCoder Grand Contest 043 (https://atcoder.jp/contests/agc043)
// Problem: A: Range Flip Find Route (https://atcoder.jp/contests/agc043/tasks/agc043_a)


// region {{{ boilerplate
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <chrono>
#include <cstdint>
#include <deque>
#include <exception>
#include <forward_list>
#include <functional>
#include <initializer_list>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#if __cplusplus >= 201703L
#   include <optional>
#   include <string_view>
#   include <variant>
#endif

using namespace std;

#if __cplusplus >= 201703L
#   define all(a)      begin(a),end(a)
#   define sz(x)       ((int)size(x))
#else
#   define all(a)      (a).begin(),(a).end()
#   define sz(x)       ((int)(x).size())
#endif

#define rep(a, b)      for(int a = 0; a < (b); ++a)
#define reps(a, b, c)  for(int a = (b); a < (c); ++a)
#define trav(a, b)     for(auto& a : b)

using ll = long long;
using ld = long double;
using u64 = uint64_t;
using u32 = uint32_t;

using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vpi = vector<pi>;

#if __cplusplus >= 201703L
#   define MAYBE_UNUSED [[maybe_unused]]
#else
#   define MAYBE_UNUSED
#endif

MAYBE_UNUSED static constexpr int INF = (int)1e9 + 5;
MAYBE_UNUSED static constexpr ll INFL = (ll)1e18 + 5;
MAYBE_UNUSED static mt19937 rng((u32)chrono::duration_cast<chrono::nanoseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count());
//endregion }}}

template <class T, size_t... Is> struct arr_helper;
template <class T> struct arr_helper<T> { using type = T; };
template <class T, size_t I, size_t... Is>
struct arr_helper<T, I, Is...> { using type = array<typename arr_helper<T, Is...>::type, I>; };
template <class T, size_t... Is> using arr = typename arr_helper<T, Is...>::type;

arr<bool, 100, 100> g;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int h, w; cin >> h >> w;
    rep(y, h) {
        string s; cin >> s;
        rep(x, w)
            g[y][x] = s[x] == '#';
    }

    vector<vpi> adj(w * h + 2);
    auto add_edge = [&](int x1, int y1, int x2, int y2) {
        adj[y1 * w + x1].emplace_back(y2 * w + x2, g[y1][x1] != g[y2][x2]);
    };
    rep(y, h) rep(x, w) {
        if (y + 1 < h)
            add_edge(x, y, x, y + 1);
        if (x + 1 < w)
            add_edge(x, y, x + 1, y);
    }
    adj[w * h].emplace_back(0, g[0][0]);
    adj[w * h - 1].emplace_back(w * h + 1, g[h-1][w-1]);

    priority_queue<pi, vpi, greater<>> q;
    vi d(sz(adj), INF);
    q.emplace(0, w * h);
    d[w * h] = 0;
    while (sz(q)) {
        int vd, v; tie(vd, v) = q.top(); q.pop();
        if (vd > d[v]) continue;
        for (auto e : adj[v]) {
            int v2, ec; tie(v2, ec) = e;
            if (d[v] + ec < d[v2])
                d[v2] = d[v] + ec, q.emplace(d[v2], v2);
        }
    }

    cout << (d[w * h + 1] / 2) << '\n';
    return 0;
}

Measured memory_bytes: 896