This page is still under construction.

Parts of this page are still being built. What you see may change.

Tree Separator

Time limit2sMemory limit512 MB

Summary
Given a tree, delete all vertices on some simple path between two chosen vertices; maximize the number of remaining components of size at least K.
Level

Hard8 of 10

Topics
Tree, Dynamic programming, DFS, Greedy
Solved
No attempts yet

Problem

You are given a tree TT with NN vertices and an integer KK. Choose two distinct vertices uu and vv of TT, and let PP be the simple path between them. Remove every vertex on PP from TT, together with every edge that has at least one endpoint on PP.

Choose uu and vv so that the number of connected components with KK or more vertices in the remaining graph is as large as possible.

Input

The input is a single test case in the following format.

N K
u1 v1
.
.
.
uN-1 vN-1

The first line has two integers NN and KK (2≤N≤1000002 \le N \le 100000, 1≤K≤N1 \le K \le N). Each of the following N−1N-1 lines describes one edge. Line i+1i+1 has two integers uiu_i and viv_i (1≤ui,vi≤N1 \le u_i, v_i \le N, ui≠viu_i \ne v_i), meaning that {ui,vi}\{u_i, v_i\} is an edge of TT. The given edges form a tree.

Output

Print the maximum number of connected components with KK or more vertices in one line.

Examples6

  1. Example 1

    Input
    2 1
    1 2
    
    Expected output
    0
    
  2. Example 2

    Input
    7 3
    1 2
    2 3
    3 4
    4 5
    5 6
    6 7
    
    Expected output
    1
    
  3. Example 3

    Input
    12 2
    1 2
    2 3
    3 4
    4 5
    3 6
    6 7
    7 8
    8 9
    6 10
    10 11
    11 12
    
    Expected output
    4
    
  4. Example 4

    Input
    3 1
    1 2
    2 3
    
    Expected output
    1
    
  5. Example 5

    Input
    3 2
    1 2
    2 3
    
    Expected output
    0
    
  6. Example 6

    Input
    9 3
    1 2
    1 3
    1 4
    4 5
    4 6
    4 7
    7 8
    7 9
    
    Expected output
    2