Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/sehrli-tangalar

Magic coins

Medium 1000 ms 256 MB 66%
Share

A chest contains coins whose values are powers of two: $1, 2, 4, 8, 16, \ldots, 2^{k}, \ldots$. Any number of coins of each value can be taken. To open the chest, one must put in coins whose values add up to exactly $S$, and the number of coins must be odd. Find the smallest number of coins in such a set. If $S$ cannot be made with an odd number of coins, print $-1$.

Making the given sum with an odd number of power-of-two coins

Input

One positive integer $S$.

Output

One integer — the smallest odd number of coins, or $-1$.

Note

$1 \le S \lt 2^{60}$

Examples

Input #1
5
Output #1
3
Input #2
7
Output #2
3

Sign in to submit a solution

Signing up is free and takes a minute.