using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;

namespace ProgrammingContestTemplateByDotNetCore
{
    #region "Input and Output Classes"

    class Scanner : IDisposable
    {
        private readonly Queue<string> _buffer;
        private readonly char[] _sep;
        private readonly TextReader _reader;

        public Scanner(TextReader reader = null, char[] sep = null)
        {
            _buffer = new Queue<string>();
            _sep = sep ?? new[] { ' ' };
            _reader = reader ?? Console.In;
        }

        public Scanner(string path, char[] sep = null)
            : this(new StreamReader(path), sep) { }

        private void CheckBuffer()
        {
            if (_buffer.Any() || _reader.Peek() == -1)
                return;

            string str = string.Empty;
            for (;
                string.IsNullOrWhiteSpace(str);
                str = _reader.ReadLine()) { }

            var values = str.Split(_sep).Where(s => !string.IsNullOrWhiteSpace(s));
            foreach (var item in values)
            {
                _buffer.Enqueue(item);
            }
        }

        public string Next()
        {
            CheckBuffer();
            return _buffer.Dequeue();
        }
        public string[] GetStringArray(int count)
            => Enumerable.Range(0, count)
                .Select(e => Next())
                .ToArray();

        public int NextInt() => int.Parse(Next());
        public int[] GetIntArray(int count)
            => Enumerable.Range(0, count)
                .Select(e => NextInt())
                .ToArray();

        public long NextLong() => long.Parse(Next());
        public long[] GetLongArray(int count)
            => Enumerable.Range(0, count)
                .Select(e => NextLong())
                .ToArray();

        public double NextDouble() => double.Parse(Next());
        public double[] GetDoubleArray(int count)
            => Enumerable.Range(0, count)
                .Select(e => NextDouble())
                .ToArray();

        public decimal NextDecimal() => decimal.Parse(Next());
        public decimal[] GetDecimalArray(int count)
            => Enumerable.Range(0, count)
                .Select(e => NextDecimal())
                .ToArray();

        public BigInteger NextBigInt() => BigInteger.Parse(Next());
        public BigInteger[] GetBigIntArray(int count)
            => Enumerable.Range(0, count)
                .Select(e => NextBigInt())
                .ToArray();

        public bool IsEnd
        {
            get
            {
                CheckBuffer();
                return !_buffer.Any();
            }
        }

        public void Dispose()
        {
            if (!_reader.Equals(Console.In))
                _reader.Dispose();
        }
    }

    class Writer : IDisposable
    {
        private readonly TextWriter _writer;
        private readonly StringBuilder _cache;
        private readonly bool _isReactive;

        public Writer(TextWriter writer = null, bool isReactive = false)
        {
            _writer = writer ?? Console.Out;
            _isReactive = isReactive;
            if (!_isReactive)
                _cache = new StringBuilder();
        }

        public Writer(string path)
            : this(new StreamWriter(path)) { }

        public Writer(bool isReactive)
            : this(null, isReactive) { }

        public void Write(object value)
        {
            if (_isReactive)
            {
                _writer.Write(value);
                _writer.Flush();
            }
            else
            {
                _cache.Append(value);
            }
        }

        public void WriteFormat(string format, params object[] values)
        {
            var value = string.Format(format, values);
            Write(value);
        }

        public void WriteLine(object value = null)
        {
            Write($"{value}{Environment.NewLine}");
        }

        public void WriteLine(string format, params object[] values)
        {
            WriteFormat($"{format}{Environment.NewLine}", values);
        }

        public void Dispose()
        {
            if (!_isReactive)
            {
                _writer.Write(_cache);
                _writer.Flush();
            }
            if (!_writer.Equals(Console.Out))
            {
                _writer.Dispose();
            }
        }
    }

    public static class Extensions
    {
        public static void Set<TKey, TValue>(
            this IDictionary<TKey, TValue> source,
            TKey key, TValue value)
        {
            if (source.ContainsKey(key))
                source[key] = value;
            else
                source.Add(key, value);
        }

        public static void Update<TKey, TValue>(
            this IDictionary<TKey, TValue> source,
            TKey key, Func<TValue, TValue> update)
        {
            if (!source.ContainsKey(key))
                source.Add(key, default(TValue));
            source[key] = update(source[key]);
        }
    }

#endregion

    class MainClass : IDisposable
    {
#region "Template"

        /// <summary> 入力を受け取る </summary>
        private readonly Scanner sc;
        /// <summary> 出力を行う </summary>
        private readonly Writer wr;
        private const string _inputFile = "input.txt";
        private const string _outFile = "output.txt";

        static void Main(string[] args)
        {
            using (new MainClass()) { }
        }

        public MainClass()
        {
            wr = new Writer(_isReactive);
            // TODO: ファイルに出力したい場合はこっち → wr = new Writer(_outFile);

#if DEBUG
            // 手元では、ファイルから入力を受け取る
            sc = new Scanner(_inputFile);
#else

            // 提出時、標準入力から受け取る
            sc = new Scanner();
#endif

            Solve();
        }

        public void Dispose()
        {
            sc?.Dispose();
            wr?.Dispose();
        }

        #endregion

        struct State
        {
            public struct Point
            { 
                public int H { get; set; }
                public int W { get; set; }
                public int Dir { get; set; }

                public bool Inside(int H, int W)
                {
                    return 0 <= this.H && this.H < H && 0 <= this.W && this.W < W;
                }
            }

            public Point Current { get; set; }
            public Point Prevent { get; set; }
        }
        void Solve()
        {
            const int INF = (int)1e9;

            int H = sc.NextInt();
            int W = sc.NextInt();
            var S = sc.GetStringArray(H)
                .Select(x => x.ToCharArray())
                .ToArray();
            int[,,] ans = new int[H, W, 2];
            for (int i = 0; i < H; i++)
            {
                for (int j = 0; j < W; j++)
                {
                    for (int k = 0; k < 2; k++)
                    {
                        ans[i, j, k] = INF;
                    }
                }
            }
            ans[0, 0, 0] = ans[0, 0, 1] = S[0][0] == '#' ? 1 : 0;

            Queue<State> que = new Queue<State>();
            que.Enqueue(new State
            {
                Current = new State.Point { H = 0, W = 0, Dir = 0 },
                Prevent = new State.Point { H = 0, W = 0, Dir = 0 }
            });
            while (que.Any())
            {
                var st = que.Dequeue();

                for (int d = 0; d < 2; d++)
                {
                    var nxtState = new State
                    {
                        Current = new State.Point { H = st.Current.H + (d == 0 ? 1 : 0), W = st.Current.W + (d == 0 ? 0 : 1), Dir = d },
                        Prevent = st.Current
                    };
                    if (!nxtState.Current.Inside(H, W)) continue;

                    var nxt =
                        ans[nxtState.Prevent.H, nxtState.Prevent.W, nxtState.Prevent.Dir] +
                        ((S[nxtState.Current.H][nxtState.Current.W] == '#' && S[nxtState.Prevent.H][nxtState.Prevent.W] == '.') ? 1 : 0);

                    if (ans[nxtState.Current.H, nxtState.Current.W, nxtState.Current.Dir] > nxt)
                    {
                        ans[nxtState.Current.H, nxtState.Current.W, nxtState.Current.Dir] = nxt;
                        que.Enqueue(nxtState);
                    }
                }
            }

            wr.WriteLine(
                Math.Min(
                    ans[H - 1, W - 1, 0],
                    ans[H - 1, W - 1, 1]
                )
            );
        }

        /// <summary>
        /// TODO: リアクティブ問題か否かを指定してね♪
        /// </summary>
        private const bool _isReactive = false;
    }
}


Measured memory_bytes: 13696