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.

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?

To find the total distance traveled by the overtaking car, you'll need to break down the problem into different phases and then add up the distances traveled in each phase.

Phase 1: Acceleration of the overtaking car

1. Use the formula v = u + at to find how long it takes for the overtaking car to reach a speed of 30 m/s:
- Initial velocity (u) = 21 m/s
- Final velocity (v) = 30 m/s
- Acceleration (a) = 2 m/s^2

Rearranging the equation: t = (v - u) / a
t = (30 - 21) / 2 = 4.5 seconds

2. Use the formula s = ut + (1/2)at^2 to find the distance traveled during acceleration:
- Initial velocity (u) = 21 m/s
- Time (t) = 4.5 seconds
- Acceleration (a) = 2 m/s^2

Rearranging the equation: s = ut + (1/2)at^2
s = (21 * 4.5) + (0.5 * 2 * 4.5^2) = 94.5 + 40.5 = 135 meters

Phase 2: Overtaking at a constant speed

3. The overtaking car continues at a constant speed of 30 m/s until it is 25 meters ahead of the other car. To calculate the time it takes to cover this distance, we can use the formula s = vt:
- Speed (v) = 30 m/s
- Distance (s) = 25 meters

Rearranging the equation: t = s / v
t = 25 / 30 = 0.833 seconds

4. The distance traveled during this phase is simply the distance traveled per second multiplied by the time taken:
- Distance traveled = 30 m/s * 0.833 seconds = 25 meters

Phase 3: Total distance traveled

5. Now, add up the distances traveled in each phase to find the total distance traveled by the overtaking car:
- Distance during acceleration = 135 meters
- Distance during constant speed = 25 meters

Total distance = 135 meters + 25 meters = 160 meters

Therefore, the overtaking car travels a total distance of 160 meters along the road between the beginning and the end of the operation.

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