For goods weighing k weights are used, nominals of weights are k serial degrees of a twain, since 20 = 1 and ending 2k-1, i.e. 20, 21, 22, …, 2k-1 gramme.
Task. What minimum number of the weights necessary for weighing of the goods of the set weight?
Notes. Goods weight in grammes – an integer. At weight weighing it is possible to put on both cups of scales. For example: for weighing of the goods in weight 15g it is possible to put on one cup of scales the goods, and on another – a combination of weights 1 + 2 + 4 + 8. But an optimal way – to add weight in 1g to the goods, and to put 16g on other cup. As a result it is necessary only 2 weights.
Stream. The input stream sets number of weights k and goods weight. The output stream should specify the minimum number of weights, or -1 if weighing is impossible.