The squirrels have invented a new way to communicate with each other! The process of sending and receiving messages requires the almighty acorn, which is said to have a string of infinite length written on its surface (don't question how it works, they don't know either). Interestingly, the almighty acorn's string consists of the concatenation of all positive integers in base . The string begins as follows:
Sending messages is straightforward, but the squirrels haven't set up the decoder yet! Decoding the message is simple: it is the -based position of the message's leftmost occurrence in the string, modulo .
You have been tasked by the squirrels to be their decoder. Given a message , please determine and output the position.
For this problem, Python users are recommended to use PYPY over CPython.
For this problem, you will NOT be required to pass all the samples in order to receive points. In addition, you must pass all previous subtasks to earn points for a specific subtask.
For all subtasks:
Subtask 1 [6%]
Subtask 2 [23%]
Subtask 3 [71%]
No additional constraints.
The first and only line contains a string consisting of only characters from to .
This problem is graded with an
identical checker. This includes whitespace characters. Ensure that every line of output is terminated with a
\n character and that there are no trailing spaces.
Output an integer representing the leftmost position of the string in the almighty acorn's string, modulo .
Sample Input 1
Sample Output 1
Sample Explanation 1
As denoted by the string,
45 first appears at
123678..., making the position .
Sample Input 2
Sample Output 2
Sample Explanation 2
can have leading zeroes. In the string, it is located at
12345678912..., making the position .