CF BUDDY
← Problems·

1037A · Packets

1300 · constructive algorithms, greedy, math

Problem: You have nn coins, each of the same value of 11.

Distribute them into packets such that any amount xx (1xn1 \leq x \leq n) can be formed using some (possibly one or all) number of these packets.

Each packet may only be used entirely or not used at all. No packet may be used more than once in the formation of the single xx, however it may be reused for the formation of other xx's.

Find the minimum number of packets in such a distribution.

Input Format: The only line contains a single integer nn (1n1091 \leq n \leq 10^9) — the number of coins you have.

Output Format: Output a single integer — the minimum possible number of packets, satisfying the condition above.

Note: In the first example, three packets with 11, 22 and 33 coins can be made to get any amount xx (1x61\leq x\leq 6).

  • To get 11 use the packet with 11 coin.
  • To get 22 use the packet with 22 coins.
  • To get 33 use the packet with 33 coins.
  • To get 44 use packets with 11 and 33 coins.
  • To get 55 use packets with 22 and 33 coins
  • To get 66 use all packets.

In the second example, two packets with 11 and 11 coins can be made to get any amount xx (1x21\leq x\leq 2).

Sample Cases

Case 1

Input

6

Output

3

Case 2

Input

2

Output

2

Similar problems

00:00:00
Loading editor…
Welcome! I'm your coding tutor for this problem. Use the chips below to reveal stored hints or get AI feedback on your code. I'll guide you step by step — never giving away the solution.

Sign in to unlock AI tutor feedback