Forest

A forest is a graph without cycles, and each of its connected components is a tree. Given an undirected graph, is it a forest? In case it is, how many trees does it have?

Input

Input consists of several graphs. Every graph starts with its number of vertices nn and its number of edges mm, followed by mm pairs xx yy indicating an edge between vertices xx and yy. Assume 1n1041 \le n \le 10^4, 0m<n0 \le m < n, that vertices are numbered from 00 to n1n-1, and that there are neither repeated edges nor edges of the type xx xx.

Output

For every graph, if it is a forest print the number of trees it has. Otherwise, print “no”.

Problem information

Author: Unknown
Translator: Albert Atserias

Generation: 2026-01-25T15:59:58.687Z

© Jutge.org, 2006–2026.
https://jutge.org