Task
You are given an undirected graph with vertices and edges. Find how many connected components the given graph has.
A connected component is a maximal subset of vertices from the graph such that for every two nodes and in the connected component, we can reach from using one or more edges.
Input data
The first line will contain two numbers, and , representing the number of vertices and edges the graph has. The next lines will contain the description of the graph, with one edge on each line.
Output data
The first line will contain a single number, representing the number of connected components the graph has.
Constraints and clarifications
- ,
- There are no two identical edges.
- For tests worth points, .
Example 1
stdin
6 3
1 2
1 4
3 5
stdout
3
Explanation
Vertexes , and are in the same connected component.
Vertexes and are in the same connected component.
Vertex is also in its own connected component.
Therefore, we have connected components.
Example 2
stdin
4 2
1 2
3 4
stdout
2