#C3802. Next Higher Number with Same Number of Set Bits

    ID: 47270 Type: Default 1000ms 256MiB

Next Higher Number with Same Number of Set Bits

Next Higher Number with Same Number of Set Bits

Given a non-negative integer (N), find the smallest integer greater than (N) that has the same number of set bits (i.e. the same number of 1's) in its binary representation.

For example, if (N = 5) (which is represented as (101) in binary), the next higher number with two set bits is (6) (represented as (110) in binary).

The problem requires reading an integer from standard input (stdin) and printing the result to standard output (stdout).

inputFormat

A single non-negative integer (N) provided via standard input.

outputFormat

Print the smallest integer greater than (N) that has the same number of set bits as (N) to standard output.## sample

5
6