There is an old stone game, played on an arbitrary general tree T. The goal is to put one stone on the root of T observing the following rules:
- At the beginning of the game, the player picks K stones and puts them all in one bucket.
- At each step of the game, the player can pick one stone from the bucket and put it on any empty leaf.
- When all of the r immediate children of a node p each has one stone, the player may remove all of these r stones, and put one of the stones on p. The other r - 1 stones are put back into the bucket, and can be used in the later steps of the game.
The player wins the game if by following the above rules, he succeeds to put one stone on the root of the tree.
You are to write a program to determine the least number of stones to be picked at the beginning of the game (K), so that the player can win the game on the given input tree.