S-Grundy game#644

S-Grundy game

2 seconds
64 megabytes
Medium

Let be a set of nonnegative integers. Define the sequence G_S(n) (n > 0) by the formula:

where is the minimal nonnegative integer not in , and is the result of bitwise addition of and modulo .

We say that a set is good if G_S(n+4) = G_S(n) for n > 4, and the values G_S(n) for n = 1, 2, 3, 4, 5, 6, 7, 8 are 0, 0, 0, 1, 0, 2, 1, 3 respectively.

Given n \geq 0, find the number of good sets whose elements do not exceed , modulo 10^9 + 7.

Input

The only line of the input contains a nonnegative integer (n \leq 10^{18}).

Output

Output a single integer: the answer to the problem.

Examples

Example 1

Loading
Loading