题目描述
Problem Description
The Baum test is a psychological test in which the subject is asked to draw a "tree" to assess their psychological state. Takahashi, who underwent this test, drew an undirected graph consisting of $ N $ vertices and $ M $ edges. Determine the number of connected components in this graph that are trees, i.e., do not contain any cycles.
Input Format
The input is given from the standard input in the following format:
$ N $ $ M $ $ u_1 $ $ v_1 $ $ u_2 $ $ v_2 $ : $ u_M $ $ v_M $
- The first line contains the number of vertices $ N $ ($ 2 $ $ ≦ $ $ N $ $ ≦ $ $ 100 $) and the number of edges $ M $ ($ 1 $ $ ≦ $ $ M $ $ ≦ $ $ N×(N-1)/2 $) in the undirected graph drawn by Takahashi, separated by spaces. The vertices are numbered from $ 1 $ to $ N $.
- The next $ M $ lines contain the information about each edge. The $ i+1 $ line ($ 1 $ $ ≦ $ $ i $ $ ≦ $ $ M $) contains the numbers of the two vertices $ u_i, $ $ v_i $ ($ 1 $ $ ≦ $ $ u_i $ $ < $ $ v_i $ $ ≦ $ $ N $) connected by edge $ i $, separated by spaces. No two vertices are directly connected by more than one edge.
Output Format
Output the number of connected components in the undirected graph drawn by Takahashi that are trees, followed by a newline.
Sample Input and Output
Sample Input #1
8 7
1 2
2 3
2 4
5 6
6 7
6 8
7 8
Sample Output #1
1
Sample Input #2
5 1
1 2
Sample Output #2
4
Sample Input #3
11 11
1 2
1 3
2 4
3 5
4 6
5 7
6 8
7 9
8 10
9 11
10 11
Sample Output #3
0
Notes/Hints
Sample Explanation 1
The graph has two connected components: one consisting of vertices $ 1, 2, 3, 4 $ and the other consisting of vertices $ 5, 6, 7, 8 $. The former does not contain any cycles, while the latter contains the cycle $ 6 - 7 - 8 - 6 $. Therefore, the number of tree-like connected components is $ 1 $.
Sample Explanation 2
A connected component consisting of a single vertex is considered a tree.
Sample Explanation 3
Although the graph resembles a tree, it is not the kind of tree being asked about in this problem.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分