I really cannot understand how to get to the answer. Thank you!

Two cars are traveling, Car A is behind the other, on a straight road. Each has a speed of 21 m/s and the distance between them is 25 m. The driver of the rear car decides to overtake the Car B ahead and does so by accelerating at 2 m/s2 up to 30 m/s after which he continues at this speed until he is 25 m ahead of the other car. How far does the overtaking car travel along the road between the beginning and end of this operation?

So,
Car A:
V: 21 m/s
a: 2m/s up to V: 30m/s until it is 25 m ahead of Car B

Car B:
V: 21 m/s
a: constant = 0

I know we are looking for the total distance traveled from Car A until it overtake Car B 25 m ahead. Then I probably need to find the exact time both car are next to each other first? Then to find which position Car A is at 25m ahead.

3 answers

using car B as the frame of reference ... car A is 25 m behind

A accelerates at 2 m/s^2 up to 9 m/s ... this takes 4.5 s
... A's ave velocity during acceleration is ... 4.5 m/s
... A's distance during acceleration is ... 4.5 s * 4.5 m/s = 20.25 m

A needs to go another 29.75 m ... 50 m - 20.25 m
... this takes ... 29.75 m / 9 m/s = 3.31 s
... so the overtaking takes ... 4.5 s + 3.31 s = 7.81 s

during the overtaking , B moves ... 21 m/s * 7.81 s = 164 m

A travels 50 m more , going from 25 m behind to 25 m in front
Just to clarity the part under the problem question is my own work to try and figure how the answer, so its not part of the problem.

So if I understand,
First we are looking for the time when the Velocity of Car B change so
Vf = Vi + ax * t
t= (Vf-Vi)/ax
t= (30-21)/2
t= 4.5 seconds

It then takes 4.5 seconds for the the Velocity of Car A to change to 30 m/s^2
But I do not get how you get a velocity of 4.5 m/s?
I do know that for the acceleration you are doing
V=(Delta x)/(Delta t)
X = (V)/(t)

also how do you get the 29.75m and the 9m/s?
B is the reference frame , so look at A's motion relative to B

A accelerates to an additional 9 m/s
... the average velocity during acceleration is ... (0 + 9) / 2 = 4.5
... it covers a distance of ... 4.5 m/s * 4.5 s = 20.25 m
... it needs to go 29.75 more meters to be 25 m ahead of B

I can explain it to you ... but I can't understand it for you