#abc138f. [abc138_f]Coincidence
[abc138_f]Coincidence
Problem Statement
Given are integers and . Find the number, modulo , of pairs of integers such that the remainder when is divided by is equal to .
What is ?
The XOR of integers and , , is defined as follows:
- When is written in base two, the digit in the 's place () is if either or , but not both, has in the 's place, and otherwise.
For example, . (In base two: .)
Constraints
Input
Input is given from Standard Input in the following format:
Output
Print the number of pairs of integers satisfying the condition, modulo .
Sample Input 1
2 3
Sample Output 1
3
Three pairs satisfy the condition: , , and .
Sample Input 2
10 100
Sample Output 2
604
Sample Input 3
1 1000000000000000000
Sample Output 3
68038601
Be sure to compute the number modulo .