Two people started simultaneously from points A and B towards each other. At the moment the person who started from A had covered two-thirds of the way, the other person had covered 2 km less than half the total distance. If it is known that when the person who started from B had covered 14 of the way, the other person was 3 km short of the midpoint. Find the distance between A and B. The speeds of the two people were constant.