110005 - 相同 Lowbit 数对

多组输入,每组给定一个正整数 R,求在区间 [1, R] 中有序数对 (x, y) 的总数,满足: lowbit(x) = lowbit(y)。 例如 (1, 3) , (3, 1), (1, 1), (3, 3) 都是合法答案。

Input

输入若干组数据,每行一个整数 R(1 ≤ R ≤ 10^18)。

Output

每组输出一行一个整数(不超过10^18),表示合法有序对总数。

Examples

Input

3
6

Output

5
17

Hint

R = 3 时: lowbit = 1:(1, 3) 共 2 个,有序对数 2 × 2 = 4; lowbit = 2:(2) 共 1 个,有序对数 1 × 1 = 1。

Time Limit 1 second
Memory Limit 128 MB
Stats
上一题 下一题