using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            input_iter = LazyLoadAllLines();
            //------------------------------------------------//
            //var n = Read<long>();
            //var s = Read();
            //var als = Read<long>(n);
            //var sls = Read(n);
            //List<List<long>> abls = new List<List<long>>();
            //List<long> cls = new List<long>();
            /*List<long> edgeNum = Enumerable.Repeat(0L, (int)n).ToList();
            for (int i = 0; i < n - 1; ++i)
            {
                abls.Add(Read<long>(2));
                abls[i].Add(i);
                abls[i].Add(-1);
                --abls[i][0];
                --abls[i][1];
                //cls.Add(Read<long>());
                ++edgeNum[(int)abls[i][0]];
                ++edgeNum[(int)abls[i][1]];
            }*/

            //als.Sort((l, r) => (r - l));
            //sls.Sort(StringComparer.OrdinalIgnoreCase);

            var h = Read<long>();
            var w = Read<long>();
            var s = Read(h);

            int[,] dp = new int[h, w];
            for (int i = 0; i < h; i++)
            {
                for (int j = 0; j < w; j++)
                {
                    dp[i, j] = int.MaxValue;
                }
            }
            dp[0, 0] = (s[0][0] == '.' ? 0 : 1);

            for (int i = 1; i < h; i++)
            {
                dp[i, 0] = (s[i - 1][0] == s[i][0] || s[i][0] == '.') ? dp[i - 1, 0] : dp[i - 1, 0] + 1;
            }

            for (int i = 1; i < w; i++)
            {
                dp[0, i] = (s[0][i - 1] == s[0][i] || s[0][i] == '.') ? dp[0, i - 1] : dp[0, i - 1] + 1;
            }

            for (int i = 1; i < h; i++)
            {
                for (int j = 1; j < w; j++)
                {
                    dp[i, j] = Math.Min(
                        (s[i - 1][j] == s[i][j] || s[i][j] == '.') ? dp[i - 1, j] : dp[i - 1, j] + 1,
                        (s[i][j - 1] == s[i][j] || s[i][j] == '.') ? dp[i, j - 1] : dp[i, j - 1] + 1
                        );
                }
            }

            Console.WriteLine(dp[h - 1, w - 1]);


            /*Stack<Data> dats = new Stack<Data>();
            dats.Push(new Data(0, 0, 0, false));
            int cnt = int.MaxValue;

            checker = new int[h, w];
            for (int i = 0; i < h; i++)
            {
                for (int j = 0; j < w; j++)
                {
                    checker[i, j] = int.MaxValue;
                }
            }

            while (dats.Count > 0)
            {
                var dat = dats.Pop();

                if (dat.row == h - 1 && dat.column == w - 1)
                {
                    if (s[dat.row][dat.column] == '#' && !dat.isTurned) ++dat.num;
                    cnt = Math.Min(cnt, dat.num);
                    continue;
                }

                if (s[dat.row][dat.column] == '#')
                {
                    int row = dat.row;
                    int col = dat.column;
                    while (row < w && s[row][col] == '#') ++row;
                    --row;
                    while (col < h && s[row][col] == '#') ++col;
                    --col;

                    if (row < h - 1) dats.Push(new Data(row + 1, col, dat.num + 1, true));
                    if (col < w - 1) dats.Push(new Data(row, col + 1, dat.num + 1, true));

                    row = dat.row;
                    col = dat.column;
                    while (col < h && s[row][col] == '#') ++col;
                    --col;
                    while (row < w && s[row][col] == '#') ++row;
                    --row;

                    CheckPush(dats, new Data(row + 1, col, dat.num + 1, true), w, h);
                    if (col < w - 1) dats.Push(new Data(row, col + 1, dat.num + 1, true));
                }
                else
                {
                    if (dat.row < h - 1) dats.Push(new Data(dat.row + 1, dat.column, dat.num, false));
                    if (dat.column < w - 1) dats.Push(new Data(dat.row, dat.column + 1, dat.num, false));
                }
            }

            if (cnt == int.MaxValue) cnt = 1;

            Console.WriteLine(cnt);*/


        }

        /*static int[,] checker;

        static void CheckPush(Stack<Data> stack, Data data, long w, long h)
        {
            if(data.row < h && data.column < w && !checker[data.row, data.column])
            {
                checker[data.row, data.column] = true;
                stack.Push(data);
            }
        }

        struct Data
        {
            public int row;
            public int column;
            public int num;
            public bool isTurned;

            public Data(int r, int c, int n, bool ist) {
                row = r; column = c; num = n; isTurned = ist;
            }
        }*/

        static IEnumerator<string> input_iter;

        static IEnumerator<string> LazyLoadAllLines(bool doSplit = true)
        {
            string line;
            if (doSplit)
            {
                do
                {
                    line = Console.ReadLine();
                    foreach (var s in line.Split(' '))
                        yield return s;
                } while (line != null);
            }
            else
            {
                do
                {
                    line = Console.ReadLine();
                    yield return line;
                } while (line != null);
            }
        }
        // single 1 elem.
        static _T Read<_T>() where _T : struct
        {
            input_iter.MoveNext();
            return (_T)Convert.ChangeType(input_iter.Current, typeof(_T));
        }
        static string Read()
        {
            input_iter.MoveNext();
            return input_iter.Current;
        }
        // single n-elems.
        static List<_T> Read<_T>(long num) where _T : struct
        {
            List<_T> res = new List<_T>();
            for (long i = 0; i < num; ++i)
            {
                input_iter.MoveNext();
                res.Add((_T)Convert.ChangeType(input_iter.Current, typeof(_T)));
            }
            return res;
        }
        static List<string> Read(long num)
        {
            List<string> res = new List<string>();
            for (long i = 0; i < num; ++i)
            {
                input_iter.MoveNext();
                res.Add(input_iter.Current);
            }
            return res;
        }
        // multiple(single type) n-elems. (Range, Edge etc.)
        static List<List<_T>> Read<_T>(long elemNum, long typeNum, bool toSort = false) where _T : struct
        {
            List<List<_T>> res = new List<List<_T>>();
            for (int i = 0; i < elemNum; ++i)
            {
                var elem = Read<_T>(typeNum);
                if (toSort) elem.Sort();
                res.Add(elem);
            }
            return res;
        }
        // multiple(multiple type) n-elems.
        static List<Tuple<_T1, _T2>> Read<_T1, _T2>(long num) where _T1 : struct where _T2 : struct
        {
            List<Tuple<_T1, _T2>> res = new List<Tuple<_T1, _T2>>();
            for (int i = 0; i < num; ++i)
            {
                res.Add(Tuple.Create(Read<_T1>(), Read<_T2>()));
            }
            return res;
        }
    }
}


Measured memory_bytes: 11172