using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    partial class Program
    {
        static long mod = 1000000007;
        static void Main()
        {
            Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
            Solve();
            Console.Out.Flush();
            Console.ReadKey();
        }

        //ここから
        static int H;
        static int W;
        static char[][] S;
        static void Solve()
        {
            Multi(out H, out W);
            S = GetCharJaggedArray(H);

            var ans = Dijkstra();
            if (S[0][0] == '#') ans++;
            Console.WriteLine(ans);

        }

        static long Dijkstra()
        {
            var dx = new int[] { 1, 0};
            var dy = new int[] { 0, 1};
            var A = Enumerable.Repeat(0, H * W).Select(s => new List<Edge>()).ToArray();
            int start = 0;
            int goal = H * W - 1;
            for (int y = 0; y < H; y++)
            {
                for (int x = 0; x < W; x++)
                {
                    var pos = y * W + x;
                    for (int v = 0; v < 2; v++)
                    {
                        var ny = y + dy[v];
                        var nx = x + dx[v];
                        var npos = ny * W + nx;
                        if (nx < 0 || W <= nx || ny < 0 || H <= ny) continue;
                        var edge = new Edge();
                        edge.to = npos;
                        if (S[y][x]=='.' && S[ny][nx] == '#') edge.cost = 1;
                        else edge.cost = 0;
                        A[pos].Add(edge);
                    }
                }
            }

            var dist = Enumerable.Repeat((long)(int.MaxValue), H * W).ToArray();
            dist[start] = 0;
            var prev = Enumerable.Repeat(0, H * W).ToArray();
            var next = new PriorityQueue<Node>();

            next.Push(new Node(start, 0));
            while (next.Count > 0)
            {
                var n = next.Peek();
                next.Pop();
                foreach (var a in A[n.node])
                {
                    var alt = dist[n.node] + a.cost;
                    if (dist[a.to] > alt)
                    {
                        dist[a.to] = alt;
                        prev[a.to] = n.node;
                        next.Push(new Node(a.to, alt));
                    }
                }
            }
            return dist[goal];
        }
    }
    class Edge
    {
        public int to;
        public long cost;
    }
    class Node : IComparable<Node>
    {
        public Node(int n, long c)
        {
            node = n; cost = c;
        }
        public int node;
        public long cost;
        public int CompareTo(Node other)
        {
            return cost < other.cost ? 1 : cost == other.cost ? 0 : -1;
        }
    }

    class PriorityQueue<T> where T : IComparable<T>
    {
        public PriorityQueue()
        {
            buffer = new List<T>();
        }


        List<T> buffer;
        public void Push(T elem)
        {
            int n = buffer.Count;
            buffer.Add(elem);
            while (n != 0)
            {
                int i = (n - 1) / 2;
                if (buffer[n].CompareTo(buffer[i]) > 0)
                {
                    T temp = buffer[n];
                    buffer[n] = buffer[i];
                    buffer[i] = temp;
                }
                n = i;
            }
        }

        public void Pop()
        {
            int n = buffer.Count - 1;
            buffer[0] = buffer[n];
            buffer.RemoveAt(n);
            for (int i = 0, j; (j = 2 * i + 1) < n;)
            {
                if ((j != n - 1) && (buffer[j].CompareTo(buffer[j + 1]) < 0)) { j++; }
                if (buffer[i].CompareTo(buffer[j]) < 0)
                {
                    T temp = buffer[j];
                    buffer[j] = buffer[i];
                    buffer[i] = temp;
                }
                i = j;
            }
        }

        public T Peek()
        {
            return buffer[0];
        }

        public int Count { get { return buffer.Count; } }
    }



    //拡張メソッド
    public static class Ex
    {
        public static List<string> FastSort(this List<string> s) { s.Sort(StringComparer.Ordinal); return s.ToList(); }
        public static string yesno(this bool b) { return b ? "yes" : "no"; }
        public static string YesNo(this bool b) { return b ? "Yes" : "No"; }
        public static string YESNO(this bool b) { return b ? "YES" : "NO"; }
    }

    partial class Program
    {
        static public string GetStr() { return Console.ReadLine().Trim(); }
        static public char GetChar() { return Console.ReadLine().Trim()[0]; }
        static public int GetInt() { return int.Parse(Console.ReadLine().Trim()); }
        static public long GetLong() { return long.Parse(Console.ReadLine().Trim()); }
        static public double GetDouble() { return double.Parse(Console.ReadLine().Trim()); }
        static public string[] GetStrArray() { return Console.ReadLine().Trim().Split(' '); }
        static public int[] GetIntArray() { return Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray(); }
        static public long[] GetLongArray() { return Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray(); }
        static public char[] GetCharArray() { return Console.ReadLine().Trim().Split(' ').Select(char.Parse).ToArray(); }
        static public double[] GetDoubleArray() { return Console.ReadLine().Trim().Split(' ').Select(double.Parse).ToArray(); }
        static public T[][] CreateJaggedArray<T>(int H, int W, T value) { return Enumerable.Repeat(0, H).Select(s => Enumerable.Repeat(value, W).ToArray()).ToArray(); }
        static public int[][] GetIntJaggedArray(int N) { return Enumerable.Repeat(0, N).Select(s => GetIntArray().ToArray()).ToArray(); }
        static public long[][] GetLongJaggedArray(int N) { return Enumerable.Repeat(0, N).Select(s => GetLongArray().ToArray()).ToArray(); }
        static public char[][] GetCharJaggedArray(int N) { return Enumerable.Repeat(0, N).Select(s => GetStr().ToCharArray()).ToArray(); }
        static public double[][] GetDoubleJaggedArray(int N) { return Enumerable.Repeat(0, N).Select(s => GetDoubleArray()).ToArray(); }

        static public void WriteObjects<T>(IReadOnlyCollection<T> values) { var array = values.ToArray(); var num = array.Length; if (num == 0) return; Console.Write(array[0]); for (int i = 1; i < num; i++) { Console.Write(" " + array[i]); } Console.WriteLine(); }

        static bool eq<T, U>() => typeof(T).Equals(typeof(U));
        static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
        static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
                           : eq<T, long>() ? ct<T, long>(long.Parse(s))
                           : eq<T, double>() ? ct<T, double>(double.Parse(s))
                           : eq<T, char>() ? ct<T, char>(s[0])
                                             : ct<T, string>(s);
        static void Multi<T>(out T a) => a = cv<T>(GetStr());
        static void Multi<T, U>(out T a, out U b)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]);
        }
        static void Multi<T, U, V>(out T a, out U b, out V c)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]);
        }
        static void Multi<T, U, V, W>(out T a, out U b, out V c, out W d)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]);
        }
        static void Multi<T, U, V, W, X>(out T a, out U b, out V c, out W d, out X e)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); e = cv<X>(ar[4]);
        }
        static void Multi<T, U, V, W, X, Y>(out T a, out U b, out V c, out W d, out X e, out Y f)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); e = cv<X>(ar[4]); f = cv<Y>(ar[5]);
        }
    }
}

Measured memory_bytes: 16480