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

read(*,*) s
l = len_trim(s)
j = 0
do i = 1, l
   if( s(i:i) == 'B' ) then
      j = j + 1
   end if
end do
m = j
k = index( s, 'B', back=.true. )
if( j*2.ge.k ) then
   write(*,*) s(k+1:l)
else
   i = k
   do while ( m>0 )
      if( s(i:i) == 'B' ) then
      else
        m = m - 1
      end if
      s(i:i) = ''
      i = i - 1
   end do
   write(*,*) adjustl( trim(s) )
end if
end program main
