Count Even and Odd BitsEasy

Count Even and Odd Bits

EasyPractice library · +10 XPbit manipulationloopscounting

Given a non-negative integer N, count the number of set bits (1s) that are at even positions and the number of set bits that are at odd positions. Bit positions are counted from right to left, starting at position 0. For example, in the binary representation of 13 (1101), the bit at position 0 is 1, position 1 is 0, position 2 is 1, and position 3 is 1. The set bits are at positions 0, 2, and 3. Positions 0 and 2 are even, and position 3 is odd. So, for N=13, the count of even-positioned set bits is 2, and the count of odd-positioned set bits is 1.

Input

A single line containing a non-negative integer N.

Output

Print two space-separated integers: the count of even-positioned set bits followed by the count of odd-positioned set bits.

Constraints

0 <= N <= 10^9

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

Example 1

Input
13
Output
2 1

Binary of 13 is 1101. Set bits at positions 0 (even), 2 (even), 3 (odd). Counts: even=2, odd=1.

Example 2

Input
7
Output
2 1

Binary of 7 is 111. Set bits at positions 0 (even), 1 (odd), 2 (even). Counts: even=2, odd=1.

Hints