How to apply single color to each ray tracing bounce

Hello folks,
i need to extract the light bounces information in a ray traced environment. Where the light (spot light) is casted from the player perspective.

My idea was to create a post process material that colors the scene differently at each light bounce. Example:
first hit - red
second hit - green
third hit - blue

Any idea on how to implement it? Or access this information on the rendering buffer?