~/algor $ cat problems/sehrli-tangalar
Magic coins
Medium
1000 ms
256 MB
66%
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$.
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