using System;
using System.Text;
using System.Collections.Generic;
using static System.Math;
using System.Linq;
using static System.Array;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;

namespace FenceRepair
{
    class Program
    {
        static long H;
        static long W;
        static string[] S;
        static long[,] map;
        static void Main(string[] args)
        {
            var HW = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            H = HW[0];
            W = HW[1];
            map = new long[H, W];
            for (int i = 0; i < H; i++)
            {
                for (int j = 0; j < W; j++)
                {
                    map[i, j] = -1;
                }
            }
            //var S2 = Console.ReadLine();
            S = new string[H];
            for (int i = 0; i < H; i++)
            {
                S[i] = Console.ReadLine().ToString();
            }

            WFS();
            Console.WriteLine(map[H-1,W-1]);
        }

        static void WFS()
        {
            var que1 = new Queue<Tuple<int, int>>();
            var que2 = new Queue<Tuple<int, int>>();
            if (S[0][0] == '#')
            {
                map[0, 0] = 1;
                que2.Enqueue(new Tuple<int, int>(0, 0));
            }
            else
            {
                map[0, 0] = 0;
                que1.Enqueue(new Tuple<int, int>(0, 0));
            }
            
            while(que1.Count > 0 || que2.Count > 0)
            {
                while (que1.Count > 0)
                {
                    Tuple<int, int> peek;
                        peek = que1.Dequeue();

                    var x = peek.Item1;
                    var y = peek.Item2;
                    //peekが.か#を調べるtrue = . false = #
                    var flag = S[x][y] == '.';
                    //右を調べる
                    if (y + 1 < W && map[x, y + 1] < 0)
                    {
                        if (flag && S[x][y + 1] != '.')
                        {
                            map[x, y + 1] = map[x, y] + 1;
                        }
                        else
                        {
                            map[x, y + 1] = map[x, y];
                        }

                        if (S[x][y + 1] == '.')
                        {
                            que1.Enqueue(new Tuple<int, int>(x, y + 1));
                        }
                        else
                        {
                            que2.Enqueue(new Tuple<int, int>(x, y + 1));
                        }

                    }

                    if (x + 1 < H && map[x + 1, y] < 0)
                    {
                        if (flag && S[x + 1][y] != '.')
                        {
                            map[x + 1, y] = map[x, y] + 1;
                        }
                        else
                        {
                            map[x + 1, y] = map[x, y];
                        }

                        if (S[x + 1][y] == '.')
                        {
                            que1.Enqueue(new Tuple<int, int>(x + 1, y));
                        }
                        else
                        {
                            que2.Enqueue(new Tuple<int, int>(x + 1, y));
                        }
                    }
                }

                while (que2.Count > 0)
                {
                    Tuple<int, int> peek;
                        peek = que2.Dequeue();
             

                    var x = peek.Item1;
                    var y = peek.Item2;
                    //peekが.か#を調べるtrue = . false = #
                    var flag = S[x][y] == '.';
                    //右を調べる
                    if (y + 1 < W && map[x, y + 1] < 0)
                    {
                        if (flag && S[x][y + 1] != '.')
                        {
                            map[x, y + 1] = map[x, y] + 1;
                        }
                        else
                        {
                            map[x, y + 1] = map[x, y];
                        }

                        if (S[x][y + 1] == '.')
                        {
                            que1.Enqueue(new Tuple<int, int>(x, y + 1));
                        }
                        else
                        {
                            que2.Enqueue(new Tuple<int, int>(x, y + 1));
                        }

                    }

                    if (x + 1 < H && map[x + 1, y] < 0)
                    {
                        if (flag && S[x + 1][y] != '.')
                        {
                            map[x + 1, y] = map[x, y] + 1;
                        }
                        else
                        {
                            map[x + 1, y] = map[x, y];
                        }

                        if (S[x + 1][y] == '.')
                        {
                            que1.Enqueue(new Tuple<int, int>(x + 1, y));
                        }
                        else
                        {
                            que2.Enqueue(new Tuple<int, int>(x + 1, y));
                        }
                    }
                }
            }
            
        }
    }

    class Heap
    {
        private long[] heap;
        private static readonly long MAX_N = 10000000;
        private static int sz    = 0;
        public Heap()
        {
            heap = new long[MAX_N];
        }
        public void push(int x)
        {
            int i = sz++;
            while(i > 0)
            {
                int p = (i - 1) / 2;
                if(heap[p] <= x)
                {
                    break;
                }
                heap[i] = heap[p];
                i = p;
            }
            heap[i] = x;
        }

        public long pop()
        {
            long ret = heap[0];
            long x = heap[--sz];
            int i = 0;
            while (i*2+1 < sz)
            {
                int a = heap[i * 2 + 1] >= heap[i * 2 + 2] ? i * 2 + 1 : i * 2 + 2;
                if (heap[a] >= x) break;
                heap[i] = heap[a];
                i = a;
            }
            heap[i] = x;
            return ret;
        }
    }
}

Measured memory_bytes: 13780