Ren has recently created a website, Ternary Search, which he intends on turning into the premier platform for competitive programmers to talk about anything.
Ren's website has slowly become more and more popular - it currently has
Ren wants to make sure that any user is able to communicate with any other user on the platform. Two users
can directly communicate with each other if and only if they are friends, so two users
Ren knows which users are friends with each other, and can force users
Constraints
Input Specification
The first line contains two space-separated positive integers
The next line contains
The next
Output Specification
Output the minimum cost needed to make sure any two users can communicate.
Sample Input
4 2
1 2 3 4
1 2
3 4
Sample Output
1
Comments