408106: GYM102986 B Sharing Cheerios

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

B. Sharing Cheeriostime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

Lang won first prize at a lottery! Unfortunately, instead of receiving lots of money, he has received a shipment of $$$n$$$ boxes of Cheerios. Obviously, Lang is not going to be able to finish too many boxes of Cheerios, but he does not know what to do with them. He reaches out to his $$$m$$$ friends that are available, and they each come one after another to share Lang's Cheerios. Lang decides to be generous, and gives each friend half of his remaining boxes of Cheerios (rounded up if necessary), in the order they come. He will continue until he either runs out of Cheerios, or he has no more available friends.

Given $$$n$$$, the number of boxes of Cheerios he has, and $$$m$$$, the number of friends he has available, determine how many friends will get Cheerios!

Input

The first line of input contains $$$n (1 \le n \le 10^9)$$$ and $$$m (1 \le m \le 50)$$$, the number of Cheerio boxes and the number of friends Lang has available, respectively.

Output

A single integer, the number of friends that Lang will give Cheerios to.

ExampleInput
15 5
Output
4

加入题单

上一题 下一题 算法标签: