cho.sh
Notes
Loading...

Social Network Service

Time limit

3s

Memory limit

256 MB

Problem

A social network can be represented as a graph: each person is a vertex, and each friendship is an edge between two vertices.

When a new idea spreads through the network, some people are selected as early adopters. A person who is not an early adopter accepts the idea only when all of that person's friends are early adopters.

In this problem, the friendship graph is a tree: every pair of vertices is connected by exactly one path, and there is no cycle. Given the friendship tree, find the minimum number of early adopters needed so that every person accepts the idea.

Input

The first line contains the number of vertices N in the friendship tree.

2 <= N <= 1,000,000, and the vertices are numbered from 1 to N.

Each of the next N - 1 lines contains two integers u and v, meaning that vertices u and v are connected by a friendship edge.

Output

Print one integer: the minimum number of early adopters needed for the idea to spread to every person in the given friendship tree.