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

namespace AC
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = ReadArrayLong();
            var H = input[0];
            var W = input[1];
            var maze = new int[H, W];
            for (int i = 0; i < H; i++)
            {
                var line = Read();
                for (int j = 0; j < W; j++)
                {
                    if (line[j] == '.') maze[i, j] = 0;
                    else maze[i, j] = 1;
                }
            }
            var step = new int[H, W];
            for (int i = 0; i < H; i++)
            {
                for (int j = 0; j < W; j++)
                {
                    step[i, j] = int.MaxValue;
                }
            }
            if (maze[0, 0] == 1)
            {
                step[0, 0] = 1;
                maze[0, 0] = 1;
            }
            else
            {
                step[0, 0] = 0;
                maze[0, 0] = 0;
            }
            for (int i = 0; i < H; i++)
            {
                for (int j = 0; j < W; j++)
                {
                    if (i == 0 && j == 0) continue;
                    var up = int.MaxValue;
                    var left = int.MaxValue;
                    if (maze[i, j] == 0)
                    {
                        if (i - 1 >= 0)
                        {
                            up = step[i - 1, j];
                        }
                        if (j - 1 >= 0)
                        {
                            left = step[i, j - 1];
                        }
                    }
                    else
                    {
                        if (i - 1 >= 0)
                        {
                            if (maze[i - 1, j] == 0)
                            {
                                up = step[i - 1, j] + 1;
                            }
                            else
                            {
                                up = step[i - 1, j];
                            }
                        }
                        if (j - 1 >= 0)
                        {
                            if (maze[i, j - 1] == 0)
                            {
                                left = step[i, j - 1] + 1;
                            }
                            else
                            {
                                left = step[i, j - 1];
                            }
                        }
                    }
                    step[i, j] = Math.Min(up, left);
                }
            }

            Console.WriteLine(step[H - 1, W - 1]);
            Console.ReadKey();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static string[] ReadArrayString() { return Read().Split(' '); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}


Measured memory_bytes: 13308