F. Leaf Sets

F. Leaf Sets
time limit per test

3 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

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≤n≤1061≤k≤106) — 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 vi and ui (1≤vi,ui≤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.

Examples
input

Copy

output

Copy

input

Copy

output

Copy

input

Copy

output

Copy

Note

令f[i]表示在第i个节点处理完所有叶子节点的最小代价
令g[i]表示在第i个节点得到最优方案时,深度最低的叶子节点的深度
那么合并子树,如果两个点之间的g[i]距离小于k就可以直接合并f[i]
否则令g[i] = min(g[x],g[y])
然后注意根节点不能是叶子节点
暴力找一下就行了
c++代码如下:

 

回复

  1. 回复 。。。

    Hello!Can you speak Chinese?I do not understand English!
    雷猴啊!

2 + 1 =