program main
    implicit none
    integer(4):: h,w
    integer(4):: i,j,change,k
    integer(4),allocatable:: cc(:,:)
    integer(4),parameter:: inf=1000000
    character(1), allocatable:: s(:,:)
    character(100):: input_s

    read*,h, w

    allocate(cc(w,h), s(w,h))

    do i=1,h
        read*, input_s
        do j=1,w
            s(j,i) = input_s(j:j)
        end do
    end do

    cc(:,:) = inf
    cc(1,1) = 0


    do i=1,h
        do j=1,w
            change=1
            if (j+1 <= w) then
                if (s(j+1,i) == s(j,i)) change=0
                cc(j+1,i) = min(cc(j+1,i), cc(j,i)+change)
            end if
            change=1
            if (i+1 <= h) then
                if (s(j,i+1) == s(j,i)) change=0
                cc(j,i+1) = min(cc(j,i+1), cc(j,i)+change)
            end if

        end do
    end do
    cc(w,h)=cc(w,h)/2
    if (s(1,1) == '#') cc(w,h)=cc(w,h)+1

    print*,cc(w,h)

    
end program main