#APC001E. Antennas on Tree

Antennas on Tree

Score : 900900 points

Problem Statement

We have a tree with NN vertices. The vertices are numbered 00 through N1N - 1, and the ii-th edge (0i<N10 \leq i < N - 1) comnnects Vertex aia_i and bib_i. For each pair of vertices uu and vv (0u,v<N0 \leq u, v < N), we define the distance d(u,v)d(u, v) as the number of edges in the path uu-vv.

It is expected that one of the vertices will be invaded by aliens from outer space. Snuke wants to immediately identify that vertex when the invasion happens. To do so, he has decided to install an antenna on some vertices.

First, he decides the number of antennas, KK (1KN1 \leq K \leq N). Then, he chooses KK different vertices, x0x_0, x1x_1, ..., xK1x_{K - 1}, on which he installs Antenna 00, 11, ..., K1K - 1, respectively. If Vertex vv is invaded by aliens, Antenna kk (0k<K0 \leq k < K) will output the distance d(xk,v)d(x_k, v). Based on these KK outputs, Snuke will identify the vertex that is invaded. Thus, in order to identify the invaded vertex no matter which one is invaded, the following condition must hold:

  • For each vertex uu (0u<N0 \leq u < N), consider the vector (d(x0,u),...,d(xK1,u))(d(x_0, u), ..., d(x_{K - 1}, u)). These NN vectors are distinct.

Find the minumum value of KK, the number of antennas, when the condition is satisfied.

Constraints

  • 2N1052 \leq N \leq 10^5
  • 0ai,bi<N0 \leq a_i, b_i < N
  • The given graph is a tree.

Input

Input is given from Standard Input in the following format:

NN

a0a_0 b0b_0

a1a_1 b1b_1

::

aN2a_{N - 2} bN2b_{N - 2}

Output

Print the minumum value of KK, the number of antennas, when the condition is satisfied.

5
0 1
0 2
0 3
3 4
2

For example, install an antenna on Vertex 11 and 33. Then, the following five vectors are distinct:

  • (d(1,0),d(3,0))=(1,1)(d(1, 0), d(3, 0)) = (1, 1)
  • (d(1,1),d(3,1))=(0,2)(d(1, 1), d(3, 1)) = (0, 2)
  • (d(1,2),d(3,2))=(2,2)(d(1, 2), d(3, 2)) = (2, 2)
  • (d(1,3),d(3,3))=(2,0)(d(1, 3), d(3, 3)) = (2, 0)
  • (d(1,4),d(3,4))=(3,1)(d(1, 4), d(3, 4)) = (3, 1)
2
0 1
1

For example, install an antenna on Vertex 00.

10
2 8
6 0
4 1
7 6
2 3
8 6
6 9
2 4
5 8
3

For example, install an antenna on Vertex 00, 44, 99.