#K85702. Connected Components in a Network
Connected Components in a Network
Connected Components in a Network
Given a network with n computers numbered from 1 to n and m communication channels that connect pairs of computers, determine the number of connected components in the network.
A connected component is a maximal set of computers where any two computers are connected by a path. Formally, if the network is represented as an undirected graph \(G = (V, E)\) with \( |V| = n \) and \( |E| = m \), your task is to compute the number of connected components.
inputFormat
The first line contains two integers n and m - the number of computers and the number of communication channels, respectively.
Each of the next m lines contains two integers u and v (1-indexed) indicating a direct communication channel between computer u and computer v.
outputFormat
Output a single integer representing the number of connected components in the network.
## sample5 3
1 2
2 3
4 5
2
</p>