Count Set BitsEasy

Count Set Bits

EasyPractice library · +10 XPbit manipulationloopsbasic

Given a single non-negative integer N, print the number of bits that are set to 1 in its binary representation. For example, if N is 13, its binary representation is 1101, which has three 1s. So the output should be 3.

Input

A single non-negative integer N.

Output

A single integer representing the count of set bits in N.

Constraints

0 <= N <= 1000

Time limit 1 s (native code; slower languages get more)Memory 256 MB13 hidden tests

Example 1

Input
13
Output
3

Binary of 13 is 1101, which has three 1s.

Example 2

Input
0
Output
0

Binary of 0 is 0, which has zero 1s.

Hints