program AGC43_A
  integer::H,W
  character(100)::S
  integer,allocatable::maze(:,:),dp(:,:)
  integer::i,j,k,dx(2)=[-1,0],dy(2)=[0,-1]
  read(*,*)H,W
  allocate(maze(H,W),dp(H,W))
  maze=0
  do i=1,H
     read(*,*)S
     do j=1,W
        if(S(j:j)=='#') maze(i,j)=1
     end do
  end do
  dp=huge(i)/2
  dp(1,1)=maze(1,1)
  do i=1,H
     do j=1,W
        do k=1,2
           dp(i,j)=min(dp(i,j),dp(max(1,i+dx(k)),max(1,j+dy(k)))+merge(1,0,maze(max(1,i+dx(k)),max(1,j+dy(k)))==0 .and. maze(i,j)==1))
           !merge(a,b,c)はcが真ならa，偽ならb
        end do
     end do
  end do
  write(*,*)dp(H,W)
end program AGC43_A