#arc066b. [arc066_b]Xor Sum
[arc066_b]Xor Sum
Problem Statement
You are given a positive integer . Find the number of the pairs of integers and such that there exist two non-negative integers and satisfying and . Here, denotes the bitwise exclusive OR. Since it can be extremely large, compute the answer modulo .
Constraints
Input
The input is given from Standard Input in the following format:
Output
Print the number of the possible pairs of integers and , modulo .
Sample Input 1
3
Sample Output 1
5
The five possible pairs of and are:
-
(Let , then , .)
-
(Let , then , .)
-
(Let , then , .)
-
(Let , then , .)
-
(Let , then , .)
Sample Input 2
1422
Sample Output 2
52277
Sample Input 3
1000000000000000000
Sample Output 3
787014179