All problems

Problem 342

Next Power of Two

Easy · 10 pts · Math, Bit Manipulation

Problem

Print the smallest power of two that is greater than or equal to N. The powers of two are 1, 2, 4, 8, 16 and so on. If N is already a power of two, print N itself. N can be as large as 10^18, so use a 64-bit integer type (in Python, integers already have unlimited size).

Input

A single integer N.

Output

Print the smallest power of two that is at least N.

Constraints

1 <= N <= 10^18

Example input

5

Example output

8

Explanation

The powers of two around 5 are 4 and 8. 4 is smaller than 5, so the smallest power of two that is at least 5 is 8.

Every problem here can be used in a RelayTrixCode team match. Create a room.

Previous: Strong Number Next: Josephus Problem