program name
    use,intrinsic :: iso_fortran_env
    implicit none
    character(10):: s
    integer(int32):: i


    read*, s
    i=1
    do while(i <= len_trim(s))
        if (s(i:i) == 'B') then
            s(i:) = s(i+1:) // ' '
            if (i>1) then
                s(i-1:) = s(i:) // ' '
                i=i-1
            end if
        else
            i=i+1
        end if
    end do
    print'(a)', s
end program name