The force applied to the cannonball and cannon is equal. The explosion inside the cannon will generate a pressure which will turn into a force on both cannonball and cannon. The cannon being heavier and fixed to the ground will move a bit, but the cannonball will be thrown away, fired.
Recall that
where and are the initial and final velocities, respecitvely; is the acceleration; and is the change in position.
So we have
(Normally, this equation has two solutions, but we omit the negative one because the car is moving in one direction.)