To solve this problem we must use Newton's second law which tells us that force is equal to the product of mass by acceleration. It is this particular case the acceleration is due to the gravitational acceleration since the body is in free fall.
Because the spaceships are traveling in the same direction, you should subtract the speed of spaceship A from the speed of spaceship B in order to calculate .