I am going to be brave here and give it a go. Perhaps if I'm overcounting or undercounting, someone will be along.
Start by arranging the R,P, and B with spaces in between and on the ends.
This gives us 4 positions to choose 3 and 3! ways to arrange the B,P,R.
After some head-scratching and trying to account for the different cases.