#Q158. 「一本通 5.2 例 4」战略游戏

「一本通 5.2 例 4」战略游戏

Description

Bob enjoys playing computer games, especially strategy games. However, he often struggles to find quick ways to beat them. Now he has a problem.

He owns an ancient castle where the roads form a tree structure. He wants to place the minimum number of soldiers on the nodes of this tree so that these soldiers can watch over all the roads.

Note: When a soldier is placed on a node, all edges connected to that node can be observed.

Please write a program that, given a tree, helps Bob calculate the minimum number of soldiers he needs to place.

Input Format

The input data represents a tree, described as follows.

The first line contains a number NN, representing the number of nodes in the tree.

The second to the (N+1)(N+1)-th lines each describe a node's information, in the order of the node's index ii, a numerical value kk, where kk indicates that there are kk edges connected to node ii, followed by kk numbers representing the indices of the connected nodes r1,r2,,rkr_1, r_2, \cdots, r_k.

For a tree with NN nodes, the node indices range from 00 to N1N-1, and each edge appears only once in the input file.

Output Format

The output contains only one number, which is the minimum number of soldiers required.

Sample 1

4
0 1 1
1 2 2 3
2 0
3 0

1

Data Range and Hint

For 100%100\% of the data, 0<N15000 < N \le 1500.