As a kid I would trace around the track. Starting with zero, I would add one if the track bent left and subtract one if it bent right. The answer needed to be +/- 12, 24, etc. because 12 make a circle.
A full circle is 360° and a curved piece makes a turn of 30°, so you need 360° / 30° = 12 pieces turning in the same direction to make a full circle.
Every time you use a piece turning the other way, you need to add an extra piece turning the way you want to complete the circle, so the difference between the directions has to be 12.
Note, however, that not every track with exactly 12 more pieces turning one way than the other necessarily makes a complete circle, straight pieces can cause the ends not to match up.