The speed of A is 40/t, and the speed of B is (S-40)/t. ..
From the first meeting to the second meeting, the two spent almost the same time.
A time: (40+90)/ (40/t)
B time: [(S-40)+(S-90)]/(S-40)/t,
So: (40+90)/(40/t) = [(S-40)+(S-90)]/(S-40)/t.
Solution: S= 105 (km)