#K2451. Find Server Clusters
Find Server Clusters
Find Server Clusters
You are given \( n \) servers labeled from 1 to \( n \) and \( m \) bidirectional connections. Each connection links two servers directly. Two servers belong to the same cluster if there is a path connecting them directly or indirectly. The task is to identify the total number of clusters in the network.
A server with no connections is considered a separate cluster.
inputFormat
The input is provided via standard input (stdin). The first line contains two integers \( n \) and \( m \) representing the number of servers and the number of connections, respectively. This is followed by \( m \) lines, each containing two integers \( a \) and \( b \), which indicate a bidirectional connection between server \( a \) and server \( b \).
outputFormat
Output a single integer to standard output (stdout) representing the total number of clusters in the network.
## sample5 4
1 2
2 3
4 5
5 4
2