Substract mesh B shape to mesh A

Hello,

When 2 meshes overlaps each other I need the overlaped part of mesh A to be shaped around the overlaped part of mesh B. Mesh A is always overlaping mesh B in a different way. How can I do that ?