#P1615E. Purple Crayon

    ID: 179 Type: RemoteJudge 2000ms 256MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>data structuresdfs and similargamesgraphsgreedymathsortingstrees*2400

Purple Crayon

No submission language available for this problem.

Description

Two players, Red and Blue, are at it again, and this time they're playing with crayons! The mischievous duo is now vandalizing a rooted tree, by coloring the nodes while playing their favorite game.

The game works as follows: there is a tree of size nn, rooted at node 11, where each node is initially white. Red and Blue get one turn each. Red goes first.

In Red's turn, he can do the following operation any number of times:

  • Pick any subtree of the rooted tree, and color every node in the subtree red.
However, to make the game fair, Red is only allowed to color kk nodes of the tree. In other words, after Red's turn, at most kk of the nodes can be colored red.

Then, it's Blue's turn. Blue can do the following operation any number of times:

  • Pick any subtree of the rooted tree, and color every node in the subtree blue. However, he's not allowed to choose a subtree that contains a node already colored red, as that would make the node purple and no one likes purple crayon.
Note: there's no restriction on the number of nodes Blue can color, as long as he doesn't color a node that Red has already colored.

After the two turns, the score of the game is determined as follows: let ww be the number of white nodes, rr be the number of red nodes, and bb be the number of blue nodes. The score of the game is w(rb)w \cdot (r - b).

Red wants to maximize this score, and Blue wants to minimize it. If both players play optimally, what will the final score of the game be?

The first line contains two integers nn and kk (2n21052 \le n \le 2 \cdot 10^5; 1kn1 \le k \le n) — the number of vertices in the tree and the maximum number of red nodes.

Next n1n - 1 lines contains description of edges. The ii-th line contains two space separated integers uiu_i and viv_i (1ui,vin1 \le u_i, v_i \le n; uiviu_i \neq v_i) — the ii-th edge of the tree.

It's guaranteed that given edges form a tree.

Print one integer — the resulting score if both Red and Blue play optimally.

Input

The first line contains two integers nn and kk (2n21052 \le n \le 2 \cdot 10^5; 1kn1 \le k \le n) — the number of vertices in the tree and the maximum number of red nodes.

Next n1n - 1 lines contains description of edges. The ii-th line contains two space separated integers uiu_i and viv_i (1ui,vin1 \le u_i, v_i \le n; uiviu_i \neq v_i) — the ii-th edge of the tree.

It's guaranteed that given edges form a tree.

Output

Print one integer — the resulting score if both Red and Blue play optimally.

Samples

Sample Input 1

4 2
1 2
1 3
1 4

Sample Output 1

1

Sample Input 2

5 2
1 2
2 3
3 4
4 5

Sample Output 2

6

Sample Input 3

7 2
1 2
1 3
4 2
3 5
6 3
6 7

Sample Output 3

4

Sample Input 4

4 1
1 2
1 3
1 4

Sample Output 4

-1

Note

In the first test case, the optimal strategy is as follows:

  • Red chooses to color the subtrees of nodes 22 and 33.
  • Blue chooses to color the subtree of node 44.
At the end of this process, nodes 22 and 33 are red, node 44 is blue, and node 11 is white. The score of the game is 1(21)=11 \cdot (2 - 1) = 1.

In the second test case, the optimal strategy is as follows:

  • Red chooses to color the subtree of node 44. This colors both nodes 44 and 55.
  • Blue does not have any options, so nothing is colored blue.
At the end of this process, nodes 44 and 55 are red, and nodes 11, 22 and 33 are white. The score of the game is 3(20)=63 \cdot (2 - 0) = 6.

For the third test case:

The score of the game is 4(21)=44 \cdot (2 - 1) = 4.