#K69637. Fully Connected Machines

    ID: 33131 Type: Default 1000ms 256MiB

Fully Connected Machines

Fully Connected Machines

This problem requires you to determine the maximum number of fully connected machines that can be assembled given a set of gears and their compatibility relationships. Consider the gears as nodes in an undirected graph and each compatibility relationship as an edge between two nodes. A fully connected machine is formed by a connected component with at least two gears. Mathematically, if \( G = (V,E) \) is the graph, you need to count the number of connected components \( C \) such that \(|C| \ge 2\).

Example: If you have 5 gears and the relationships are given by the edges between gears (1, 2), (1, 3), (4, 5), and (2, 3), then there are two connected components: one connecting gears 1, 2, 3 and another connecting gears 4 and 5. Thus, the answer is 2.

inputFormat

The input is given from stdin and has the following format:

N M
u1 v1
u2 v2
... 
um vm

where the first line contains two integers \(N\) (the number of gears) and \(M\) (the number of compatibility relationships). Each of the next \(M\) lines contains two integers \(u\) and \(v\), indicating that gear \(u\) is compatible with gear \(v\) (and vice versa). If \(M = 0\) then no further lines follow.

outputFormat

The output should be printed to stdout and contain a single integer: the maximum number of fully connected machines (i.e. the number of connected components with at least 2 gears).

## sample
5 4
1 2
1 3
4 5
2 3
2