Pls help and solution :
Ninja has been appointed as a data scientist for a MNC. He has been provided with a huge list of people who belong to some countries. He doesn’t know who belongs to which country, but he knows which two people belong to the same country. Now, he has been asked to find the total number of unique countries this group of people belong to.
Ninja has many other projects to work on, therefore he has passed on this task to you. Are you up to the challenge?
First line of input contains two space separated integers representing the total number of people in the group (n) and number of pairs of people § whose country is known to Ninja.
Next p lines contain two integers representing which two people belong to the same country.
Print the number of unique countries the given group of people belong to.
Sample Input 1:
Sample Output 1:
Person 0,1 and 3 belong to the same country. No information about person 2 is mentioned. Hence, we can say that person 2 belongs to a separate country than that of person 0,1 and 3. Therefore, there are people from 2 countries in the given group.
Sample Input 2:
Sample Output 2: