In the arrangement shown below, two trucks A and B are held in position with spring compressed. When they are released and the spring has fallen away, A is found to be moving to the left at 2 m/s. The energy stored in the compressed spring was (a) 12 J (b) 24 J (c) 18 J (d) 36 J