There is a tree of N nodes and a integer k.In one operation you can do the following . Choose a node X other than the root node. If the distance between root and the parent of X is less than that of X ( where 1<=X<=N ) . Then X will be disconnected from it's original parent and X will be directly get connected to root. Height of the tree is the maximum distance from root to any node of tree . So find the minimum height of the tree after applying the above operation at most K times
EDIT 1 : THIS TREE IS ROOTED AT 1 AND EDGES ARE UNDIRECTED INPUT FORMAT: First line contains N and K . Next N-1 line contains two integers u and v denoting that there is an edge between u and v