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

~/algor $ cat problems/nolgacha-qadamlar

Steps to zero

Easy 1000 ms 64 MB 26%
Share

A positive integer $n$ is given. At each step: if the number is even, it is divided by two; if it is odd, $1$ is subtracted from it. How many steps are needed until the number becomes $0$?

From 14 to zero: a chain of halving and subtracting one

Input

One positive integer $n$.

Output

One integer — the number of steps.

Note

$1 \le n \le 10^{18}$

Examples

Input #1
14
Output #1
6
Input #2
1
Output #2
1

Sign in to submit a solution

Signing up is free and takes a minute.