Use the Difference Matte to generate a matte clip from two source clips with the same background but different foreground elements.
To access the Difference Matte menu, use:
This node accepts a front and back clip as input, and outputs a result.
The Difference Matte allows you to remove an image from one context and add it to another. The matte is created using the Tolerance and Softness values that you specify.