A large river has two ports, A and B. Water flows from A to B at a speed of 4 km/h. Two ships, A and B, sail from A to B at the same time, and they sail back and forth between A and B without stopping. The speed of A in still water is 28 km/h, and the speed of B in still water is 20 km/h. It is known that the place where the two ships meet face-to-face for the second time is 40 kilometers away from the place where A ship catches up with B ship for the second time (excluding the time when A and B were at A at the beginning), find the distance between the two ports of A and B ．
一条大河有A、B两个港口，水由A流向B，水流速度是4千米/小时．甲、乙两船同时由A向B行驶，各自不停地在A、B之间往返航行，甲在静水中的速度是28千米/小时，乙在静水中速度是20千米/小时，已知两船第二次迎面相遇地点与甲船第二次追上乙船(不算开始时甲、乙在A处的那一次)的地点相距40千米，求A、B两港口的距离．
<gadget id="calculator">1 / 2</gadget>
<output>1/2 = around 0.5</output>

<gadget id="calculator">1 / 3</gadget>
<output>1/3 = around 0.333333</output>

<gadget id="calculator">(1/2) - (1/3)</gadget>
<output>1/6 = around 0.166667</output>

<gadget id="calculator">40 / (1/6)</gadget>
<output>240</output>

<result>240</result>