You've passed the Only Level TOO.
Your name isn't Mario but you fall down from a pipe.
You find an elephant in a room.
It speaks.
You now know where this is going. The elephant speaks:
" The *digital sum* of an integer in base $b$ is the sum of its digits when it is written in base $b$. The *digital root* of an integer in base $b$ is the unique digit obtained by repeatedly computing the digital sum in base $b$ until only one digit remains.
Let $f_b (k)$ be the digital root of the integer $k$ in base $b$.
We say that the pair $(k, b)$ is *cool* if and only if $(f_b (0), f_b (k), f_b (2 k), \\dots, f_b ((b -1) k))$ is a permutation of $(0, 1, 2, \\dots, b -1)$.
Given two integers $k '$ and $b '$, find the number of cool pairs $(k, b)$ such that $1 <= k <= k '$ and $2 <= b <= b '$, modulo $10^6$. "
The input consists of a single line containing two space-separated integers $k '$ and $b '$.
*Constraints*
Output a single line containing a single integer denoting the answer.
## Input
The input consists of a single line containing two space-separated integers $k '$ and $b '$. *Constraints* $1 <= k ' <= 5 dot.op 10^9$ $2 <= b ' <= 5 dot.op 10^9$
## Output
Output a single line containing a single integer denoting the answer.
[samples]
**Definitions**
Let $ f_b(k) $ denote the digital root of $ k $ in base $ b $, defined as the repeated sum of digits in base $ b $ until a single digit is obtained.
**Constraints**
Given integers $ k' \in \mathbb{Z}^+ $, $ b' \in \mathbb{Z}^+ $ with $ 1 \leq k' \leq 10^6 $, $ 2 \leq b' \leq 10^6 $.
**Objective**
Count the number of pairs $ (k, b) $ such that:
- $ 1 \leq k \leq k' $,
- $ 2 \leq b \leq b' $,
- The sequence $ \left( f_b(0), f_b(k), f_b(2k), \dots, f_b((b-1)k) \right) $ is a permutation of $ \{0, 1, 2, \dots, b-1\} $.
Output the count modulo $ 10^6 $.