Several car companies exist in such a way that each company can control a large share of sales in different markets. You are required to perform a simulation that modifies the results after any mergers that happen between these companies.
Your task is to determine the minimum number of mergers that must be performed between the car companies to ensure that a market is controlled by no more than two separate companies.
Note: A merger between two companies results in a single company that controls the same markets as the two previous companies.
Input format
Output format
Print an integer denoting the minimum number of mergers.
Constraints
1≤n≤51≤m≤31≤market_id≤105
Each of the markets is controlled by less than or equal to 2 companies. So no mergers are required.