atcoder#ABC223G. [ABC223G] Vertex Deletion

[ABC223G] Vertex Deletion

Score : 600600 points

Problem Statement

Given is a tree with NN vertices. The vertices are numbered 1,2,,N1,2,\ldots,N, and the ii-th edge (1iN1)(1 \leq i \leq N-1) connects Vertex uiu_i and Vertex viv_i.

Find the number of integers ii (1iN)(1 \leq i \leq N) that satisfy the following condition.

  • The size of the maximum matching of the graph obtained by deleting Vertex ii and all incident edges from the tree is equal to the size of the maximum matching of the original tree.

Constraints

  • 2N2×1052 \leq N \leq 2 \times 10^5
  • 1ui<viN1 \leq u_i < v_i \leq N
  • The given graph is a tree.
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN

u1u_1 v1v_1

u2u_2 v2v_2

\vdots

uN1u_{N-1} vN1v_{N-1}

Output

Print the answer.

3
1 2
2 3
2

The size of the maximum matching of the original tree is 11.

The size of the maximum matching of the graph obtained by deleting Vertex 11 and all incident edges from the tree is 11.

The size of the maximum matching of the graph obtained by deleting Vertex 22 and all incident edges from the tree is 00.

The size of the maximum matching of the graph obtained by deleting Vertex 33 and all incident edges from the tree is 11.

Thus, two integers i=1,3i=1,3 satisfy the condition, so we should print 22.

2
1 2
0
6
2 5
3 5
1 4
4 5
4 6
4