Skip to content
C

Connected Components

Easyjavapythonccppjavascript

Given an undirected graph, count how many connected components it has.

Input Format

The first line contains two integers V and E. Each of the next E lines contains an undirected edge u v.

Output Format

Print the number of connected components.

Input (stdin)

Output

Run your code to see output here...