Brush Hour
Did you know that in Adelaide, pride month is in November? To prepare for this year's upcoming pride, the mayor has tasked you with painting the town all sorts of colors.
Adelaide can be represented as a tree, consisting of buildings, numbered from
to
, with
roads connecting them. To color the buildings, you have a powerful tool at your disposal: paint bombs. When you set off a bomb at a building, that building itself and all buildings directly connected to it by a single road, will get splattered in bright paint.
As fun as this is, you don't want to waste any paint! What is the minimum number paint bombs needed to color every building in the city?
Input
The first line contains an integer
, the number of buildings in Adelaide.
The next lines contain two integers
and
, indicating that there is a bidirectional road between buildings
and
.
Output
Output the minimum number of paint bombs required to paint the entire town.
Example
Input 1
7
1 2
2 3
3 4
3 5
5 6
6 7
Output 1
3
3 paint bombs, placed at buildings 2 (red), 3 (yellow) and 6 (blue) can paint the whole town, as shown below.
Input 2
5
1 3
3 2
4 3
3 5
Output 2
1
1 paint bomb, placed at building 3, can paint the whole town.
Input 3
5
1 2
2 3
3 4
4 5
Output 3
2
2 paint bombs, placed at buildings 2 and 4, can paint the whole town.
Comments