This problem is a programming version of Problem 36 from projecteuler.net
The decimal number, (binary), is palindromic in both bases.
Find the sum of all natural numbers, less than , which are palindromic in base and base .
(Please note that the palindromic number, in either base, may not include leading zeros.)
Input Format
Input contains two integers and .
Constraints
Output Format
Print the answer corresponding to the test case.
Sample Input
10 2
Sample Output
25
Explanation
These numbers are palindromic in their decimal as well as base representation: . Their sum is