import std;
import core.bitop;

ulong MAX = 100_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "x", long, "y");
alias PQueue(T, alias less = "a>b") = BinaryHeap!(Array!T, less);

void main()
{
    long h, w;
    scan(h, w);
    auto s = new string[](h);
    foreach (ref e; s)
    {
        e = sread();
    }
    auto costs = new long[][](h, w);
    costs.each!(x => x[] = INF);

    void bfs()
    {
        bool intoBlack(Pair from, Pair to)
        {
            return s[from.x][from.y] == '.' && s[to.x][to.y] == '#';
        }

        costs[0][0] = s[0][0] == '#' ? 1 : 0;
        auto q = DList!(Pair)(Pair(0, 0));
        while (!q.empty())
        {
            auto p = q.front();
            q.removeFront();

            costs[p.x][p.y] = min(costs[p.x > 0 ? p.x - 1 : p.x][p.y] + intoBlack(Pair(p.x > 0
                    ? p.x - 1 : p.x, p.y), p), costs[p.x][p.y > 0
                    ? p.y - 1 : p.y] + intoBlack(Pair(p.x, p.y > 0 ? p.y - 1 : p.y), p));

            if (p.x + 1 < h)
                q.insertBack(Pair(p.x + 1, p.y));
            if (p.y + 1 < w)
                q.insertBack(Pair(p.x, p.y + 1));
        }
    }

    bfs();
    // costs.each!(x => x.writeln());
    writeln(costs[h - 1][w - 1]);
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}
