There are N cities in a country. Some pairs of cities are connected by bidirectional roads. Eunjin wants to modify some roads so that every city becomes connected to every other city, while using as few modifications as possible.
One modification is performed as follows.
- Choose four cities A, B, C, and D such that A and B are connected by a road, C and D are connected by a road, and none of A-C, A-D, B-C, or B-D is currently connected by a road.
- Remove the roads A-B and C-D.
- Add either the roads A-C and B-D, or the roads A-D and B-C.
Given N and the road information, find the minimum number of road modifications needed.