Line segment AB is on square ABCD. Segment EF on equilateral triangle EFG is 12 units longer than AB. Square ABCD and triangle EFG have equal perimeters. What is the length of AB?