Question
Interesting XOR

You are given an integer C. Let d be the smallest integer such that 2d is strictly greater than C. Consider all pairs of non-negative integers (A,B) such that A,B < 2d and A⊕B=C (⊕ denotes the bitwise XOR operation). Find the maximum value of A⋅B over all these pairs.

Input
The only line of input contains an integer C.

Constraints:
1 ≤ C ≤ 109
Output
Return the integer denoting the the maximum possible product A⋅B.
Example
Sample Input:
13
Sample Output:
70
Explanation
The binary representation of 13 is "1101". We can use A=10("1010") and B=7("0111"). This gives us the product 70. No other valid pair (A,B) can give us a larger product.

Online