Xenny was a teacher and his class consisted of NN boys and NN girls. He took all his students to the playground and asked them to stand in a straight line. The boys and the girls formed a perfect line, but Xenny seemed unhappy. He wanted them to form an alternating sequence of boys and girls, i.e., he wanted that after a boy, there should be a girl in the line, and vice-versa.
In order to form an alternating sequence, a boy and a girl could swap their positions.
Given the original sequence in which the boys and girls were standing, find the minimum number of swaps required to form an alternating sequence.
Note: An alternating sequence can start either with a boy or a girl.