Two trains, A and B, leave opposite places A and B at the same time. They meet for the first time at a distance of 40 kilometers from A. They continue to move forward after meeting, and return immediately after reaching the destination. The second encounter is 20 kilometers away from place B. How many kilometers are there between places A and B?
甲、乙两列车同时从A、B两地相对开出，第一次在离A地40千米处相遇，相遇后继续前进，到达目的地后又立即返回．第二次相遇在离B地20千米处，A、B两地相距多少千米？
<gadget id="calculator">40 * 3</gadget>
<output>120</output>

<gadget id="calculator">120 - 20</gadget>
<output>100</output>

<result>100</result>