module ch
  implicit none
  type char
     character(100)      :: n
  end type char
  type(char),allocatable :: s(:)
end module ch
program main
  
  use ch, only : s
  implicit none
  
  integer              ::  h, w  
  integer              ::  i, j
  integer,allocatable  ::  ss(:,:), sb(:,:)

  read(*,*) h, w
  allocate( s(h) )
  allocate( ss(h,w) )
  allocate( sb(h,w) )
  do i = 1, h
    read(*,*) s(i)%n
  end do
  
  ss = 0
  do i = 1, h
    do j = 1, w
    
      if( s(i)%n(j:j) == "#" ) then
        ss(i,j) = ss(i,j) + 1
      end if
      
      if( i == 1 .and. j /= 1 ) then
        ss(i,j) = ss(i,j) + ss(i,j-1) 
        if ( s(i)%n(j:j) == "#" .and. s(i)%n(j-1:j-1) == "#" ) then
          ss(i,j) = ss(i,j) - 1  
        end if
      end if

      if( i /= 1 .and. j == 1 ) then
        ss(i,j) = ss(i,j) + ss(i-1,j)
        if ( s(i)%n(j:j) == "#" .and. s(i-1)%n(j:j) == "#" ) then
          ss(i,j) = ss(i,j) - 1  
        end if
      end if

      if( i /= 1 .and. j /= 1 ) then
        if( ss(i,j-1) <= ss(i-1,j) ) then   
          ss(i,j) = ss(i,j) + ss(i,j-1) 
          if ( s(i)%n(j:j) == "#" .and. s(i)%n(j-1:j-1) == "#" ) then
            ss(i,j) = ss(i,j) - 1  
          end if
        else
          ss(i,j) = ss(i,j) + ss(i-1,j)
          if ( s(i)%n(j:j) == "#" .and. s(i-1)%n(j:j) == "#" ) then
            ss(i,j) = ss(i,j) - 1  
          end if
        end if
      end if

    end do
  end do
  
  !print*, ss(h,w)
  
  sb = 0
  do i = 1, h
    do j = 1, w
    
      if( s(i)%n(j:j) == "." ) then
        sb(i,j) = sb(i,j) + 1
      end if
      
      if( i == 1 .and. j /= 1 ) then
        sb(i,j) = sb(i,j) + sb(i,j-1) 
        if ( s(i)%n(j:j) == "." .and. s(i)%n(j-1:j-1) == "." ) then
          sb(i,j) = sb(i,j) - 1  
        end if
      end if
 
      if( i /= 1 .and. j == 1 ) then
        sb(i,j) = sb(i,j) + sb(i-1,j)
        if ( s(i)%n(j:j) == "." .and. s(i-1)%n(j:j) == "." ) then
          sb(i,j) = sb(i,j) - 1  
        end if
      end if
 
      if( i /= 1 .and. j /= 1 ) then
        if( sb(i,j-1) <= sb(i-1,j) ) then   
          sb(i,j) = sb(i,j) + sb(i,j-1) 
          if ( s(i)%n(j:j) == "." .and. s(i)%n(j-1:j-1) == "." ) then
            sb(i,j) = sb(i,j) - 1  
          end if
        else
          sb(i,j) = sb(i,j) + sb(i-1,j)
          if ( s(i)%n(j:j) == "." .and. s(i-1)%n(j:j) == "." ) then
            sb(i,j) = sb(i,j) - 1  
          end if
        end if
      end if
 
    end do
  end do
    
  if( ss(h,w) <= (sb(h,w)+1)) then
    print*, ss(h,w)
  else
    print*, sb(h,w)+1
  end if

end program main
