#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef double db;
typedef string str;

typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<db, db> pd;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<db> vd;
typedef vector<str> vs;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<pd> vpd;

#define mp make_pair
#define f first
#define s second
#define sz(x) (int)x.size()
#define len(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define rsz resize
#define ins insert
#define ft front()
#define bk back()
#define pf push_front
#define pb push_back
#define eb emplace_back
#define ep emplace
#define lb lower_bound
#define ub upper_bound

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i,0,a)
#define ROF(i, a, b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i, a) ROF(i,0,a)
#define trav(a, x) for (auto& a: x)

const ld PI = acos((ld) -1);
const int xd[4] = {1, 0, -1, 0}, yd[4] = {0, 1, 0, -1};
mt19937 rng((uint32_t) chrono::steady_clock::now().time_since_epoch().count());

template<class T>
bool ckmin(T &a, const T &b) {
    return b < a ? a = b, 1 : 0;
}

template<class T>
bool ckmax(T &a, const T &b) {
    return a < b ? a = b, 1 : 0;
}

template<class T>
bool reorder(T &a, T &b) {
    return (a > b) ? swap(a, b), 1 : 0;
}

// INPUT
template<class A>
void re(complex<A> &c);

template<class A, class B>
void re(pair<A, B> &p);

template<class A>
void re(vector<A> &v);

template<class A, size_t SZ>
void re(array<A, SZ> &a);

template<class T>
void re(T &x) { cin >> x; }

void re(db &d) {
    str t;
    re(t);
    d = stod(t);
}

void re(ld &d) {
    str t;
    re(t);
    d = stold(t);
}

template<class H, class... T>
void re(H &h, T &... t) {
    re(h);
    re(t...);
}

template<class A>
void re(complex<A> &c) {
    A a, b;
    re(a, b);
    c = {a, b};
}

template<class A, class B>
void re(pair<A, B> &p) { re(p.f, p.s); }

template<class A>
void re(vector<A> &x) { trav(a, x) re(a); }

template<class A, size_t SZ>
void re(array<A, SZ> &x) { trav(a, x) re(a); }

// TO_STRING
#define ts to_string

str ts(char c) { return str(1, c); }

str ts(bool b) { return b ? "true" : "false"; }

str ts(const char *s) { return (str) s; }

str ts(str s) { return s; }

template<class A>
str ts(complex<A> c) {
    stringstream ss;
    ss << c;
    return ss.str();
}

str ts(vector<bool> v) {
    str res = "{";
    F0R(i, sz(v)) res += char('0' + v[i]);
    res += "}";
    return res;
}

template<size_t SZ>
str ts(bitset<SZ> b) {
    str res = "";
    F0R(i, SZ) res += char('0' + b[i]);
    return res;
}

template<class A, class B>
str ts(pair<A, B> p);

template<class T>
str ts(T v) { // containers with begin(), end()
    bool fst = 1;
    str res = "{";
    for (const auto &x: v) {
        if (!fst) res += ", ";
        fst = 0;
        res += ts(x);
    }
    res += "}";
    return res;
}

template<class A, class B>
str ts(pair<A, B> p) {
    return "(" + ts(p.f) + ", " + ts(p.s) + ")";
}

// OUTPUT
template<class A>
void pr(A x) { cout << ts(x); }

template<class H, class... T>
void pr(const H &h, const T &... t) {
    pr(h);
    pr(t...);
}

void ps() { pr("\n"); } // print w/ spaces
template<class H, class... T>
void ps(const H &h, const T &... t) {
    pr(h);
    if (sizeof...(t)) pr(" ");
    ps(t...);
}

// DEBUG
void DBG() { cerr << "]" << endl; }

template<class H, class... T>
void DBG(H h, T... t) {
    cerr << ts(h);
    if (sizeof...(t)) cerr << ", ";
    DBG(t...);
}

#ifdef LOCAL // compile with -DLOCAL
#define dbg(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
#else
#define dbg(...) 0
#endif


// REINITIALIZE ARRAYS BETWEEN TCs

/**
 * Description: Use in place of \texttt{complex<T>}.
 * Source: http://codeforces.com/blog/entry/22175, KACTL
 * Verification: various
 */

string testinput = R"(3 3
.##
.#.
##.
)";
typedef ll T;

int sgn(T a) { return (a > 0) - (a < 0); }

T sq(T a) { return a * a; }

namespace Point {
    typedef pair<T, T> P;
    typedef vector<P> vP;

    T norm(const P &p) { return sq(p.f) + sq(p.s); }

    T abs(const P &p) { return sqrt(norm(p)); }

    T arg(const P &p) { return atan2(p.s, p.f); }

    P conj(const P &p) { return P(p.f, -p.s); }

    P perp(const P &p) { return P(-p.s, p.f); }

    P dir(T ang) { return P(cos(ang), sin(ang)); }

    P operator-(const P &l) { return P(-l.f, -l.s); }

    P operator+(const P &l, const P &r) {
        return P(l.f + r.f, l.s + r.s);
    }

    P operator-(const P &l, const P &r) {
        return P(l.f - r.f, l.s - r.s);
    }

    P operator*(const P &l, const T &r) {
        return P(l.f * r, l.s * r);
    }

    P operator*(const T &l, const P &r) { return r * l; }

    P operator/(const P &l, const T &r) {
        return P(l.f / r, l.s / r);
    }

    P operator*(const P &l, const P &r) {
        return P(l.f * r.f - l.s * r.s, l.s * r.f + l.f * r.s);
    }

    P operator/(const P &l, const P &r) {
        return l * conj(r) / norm(r);
    }

    P &operator+=(P &l, const P &r) { return l = l + r; }

    P &operator-=(P &l, const P &r) { return l = l - r; }

    P &operator*=(P &l, const T &r) { return l = l * r; }

    P &operator/=(P &l, const T &r) { return l = l / r; }

    P &operator*=(P &l, const P &r) { return l = l * r; }

    P &operator/=(P &l, const P &r) { return l = l / r; }

    P unit(const P &p) { return p / abs(p); }

    T dot(const P &a, const P &b) { return a.f * b.f + a.s * b.s; }

    T cross(const P &a, const P &b) { return a.f * b.s - a.s * b.f; }

    T cross(const P &p, const P &a, const P &b) {
        return cross(a - p, b - p);
    }

    P reflect(const P &p, const P &a, const P &b) {
        return a + conj((p - a) / (b - a)) * (b - a);
    }

    P foot(const P &p, const P &a, const P &b) {
        return (p + reflect(p, a, b)) / (T) 2;
    }

    bool onSeg(const P &p, const P &a, const P &b) {
        return cross(a, b, p) == 0 && dot(p - a, p - b) <= 0;
    }

    ostream &operator<<(ostream &os, const P &p) {
        return os << "(" << p.f << "," << p.s << ")";
    }
};

void solve(int ti) {
    int h, w;
    re(h, w);

    vector<vi> arr(h, vi(w));
    trav(row, arr) {
        trav(cell, row) {
            char c;
            re(c), cell = (c == '.') ? 0 : 1;
        }
    }

    vector<vi> inv(h, vi(w, INT_MAX));
    inv[h - 1][w - 1] = arr[h - 1][w - 1];
    R0F(sum, h + w - 1) {
        R0F(j, w) {
            int i = sum - j;
            if (i >= 0 and i < h and j >= 0 and j < w) {
                auto &target = inv[i][j];
                auto curr = arr[i][j];
                if (i + 1 < h) {
                    auto next = inv[i + 1][j];
                    auto last = next % 2;
                    target = min(((last == curr) ? 0 : 1) + next, target);
                }
                if (j + 1 < w) {
                    auto next = inv[i][j + 1];
                    auto last = next % 2;
                    target = min(((last == curr) ? 0 : 1) + next, target);
                }
                cerr << target;
            }
            cerr << endl;
        }
    }
    cout << (arr[0][0] + inv[0][0]) / 2 << endl;
}

int main() {
    bool online = false;
    try {
        ifstream inFile;
        inFile.open("test.txt");
        if (!inFile) {
            online = true;
        }
        inFile.close();
    } catch (...) {
        online = true;
    }

    istringstream iss(testinput);
    if (not online) {
        cout << "---local mode---" << endl;
        cin.rdbuf(iss.rdbuf());
    }
    // setIO("A");
//    int T = 1;
//    { re(T); }
//    FOR(i, 1, T + 1) {
//        cout << "Case #" << i << ": ";
    solve(0);
//        solve(i);
//    }
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
*/



Measured memory_bytes: 384