Assume we have a number line, where the tail of the worm is at x=0. This means that the head of the worm is at x=15.
Also, we know that the coordinate of the head of the worm follows this equation:

Where
is the time in seconds. In fact, we know that the worm gains 2 centimeters per second.
Now, assume that the ant also starts at x=0, and walks with a certain rate of
centimeters per second. This means that the equation for the position of the ant is

Now, we know that after 5 seconds the ant is in the same position as the head of the worm, which means

We know the equation for both expressions, so let's subtitute them in:

So, the ant walks at a rate of 5cm per second.