Codeforces Round 510 (Div. 2)
F
Leaf Sets
Codeforces
2400
原题
← E→
翻译中…

You are given an undirected tree, consisting of $n$ vertices.

翻译中…

The vertex is called a leaf if it has exactly one vertex adjacent to it.

翻译中…

The distance between some pair of vertices is the number of edges in the shortest path between them.

翻译中…

Let's call some set of leaves beautiful if the maximum distance between any pair of leaves in it is less or equal to $k$.

翻译中…

You want to split all leaves into non-intersecting beautiful sets. What is the minimal number of sets in such a split?

翻译中…

Input

翻译中…

The first line contains two integers $n$ and $k$ ($3 \le n \le 10^6$, $1 \le k \le 10^6$) — the number of vertices in the tree and the maximum distance between any pair of leaves in each beautiful set.

翻译中…

Each of the next $n - 1$ lines contains two integers $v_i$ and $u_i$ ($1 \le v_i, u_i \le n$) — the description of the $i$-th edge.

翻译中…

It is guaranteed that the given edges form a tree.

翻译中…

Output

翻译中…

Print a single integer — the minimal number of beautiful sets the split can have.

翻译中…

Note

翻译中…

Here is the graph for the first example:

翻译中…

image

翻译中…

样例

Input #1
9 3
1 2
1 3
2 4
2 5
3 6
6 7
6 8
3 9
Output #1
2
InputCopy OutputCopy
Input #2
5 3
1 2
2 3
3 4
4 5
Output #2
2
InputCopy OutputCopy
Input #3
6 1
1 2
1 3
1 4
1 5
1 6
Output #3
5
InputCopy OutputCopy
题目信息
题号
1042F
时间限制
3 s
内存限制
256 MB
标签
数据结构
DFS 及类似
并查集
图论
贪心
排序
树

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。