program main
implicit none
integer :: i, j, k, l, nb
character :: s*10, t*10

read(*,*) s
l = len(s)
nb = 0
j = l
do i = l, 1, -1
   if( s(i:i) == 'B' ) then
      nb = nb + 1
   else
      if( nb > 0 ) then
         nb = nb - 1
      else
         t(j:j) = s(i:i)
         j = j -1
      end if
   end if
end do
write(*,*) t(j+1:10)



end program main
