Time limit
2s
Memory limit
128 MB
There is one molecule made of N atoms. The atoms are numbered from 1 to N. The molecule has exactly N-1 bonds, and every atom is connected through bonds, so the bond structure is a tree.
During an experiment, a molecule made of exactly M atoms is needed. The chosen atom types do not matter, but the M atoms must be connected as one molecule.
One decomposition reaction breaks exactly one bond in the current molecule and splits it into two molecules. After each split, you may choose one of the two resulting molecules and continue decomposing it. You want to minimize the number of decomposition reactions needed until a molecule with exactly M atoms is obtained.
Given the bond structure, compute the minimum number of decomposition reactions required.
The first line contains two integers N and M (1 ≤ M ≤ N ≤ 150).
Each of the next N-1 lines contains two distinct atoms A and B (1 ≤ A, B ≤ N) that form a bond. This means atoms A and B are directly connected.
Print the minimum required number of decomposition reactions.
If the bond between atoms 1 and 3 is broken, a molecule consisting of atoms 1, 2, 6, 7, and 8 can be obtained.