AT_abc465_e [ABC465E] Digit Circus
Description
Find, modulo $ 998244353 $ , the number of integers $ x $ with $ 1 \leq x \leq N $ that satisfy **exactly one** of the following three conditions.
- $ x $ is a multiple of $ 3 $ .
- The decimal representation of $ x $ contains `3`.
- Exactly three different digits are used in the decimal representation of $ x $ .
Here, the decimal representation of an integer should not have unnecessary leading `0`s.
Input Format
The input is given from Standard Input in the following format:
> $ N $
Output Format
Output the answer.
Explanation/Hint
### Sample Explanation 1
Among the integers from $ 1 $ to $ 45 $ , there are $ 19 $ integers satisfying exactly one of the conditions in the problem statement, as follows.
- There are $ 10 $ integers satisfying only the first condition: $ 6, 9, 12, 15, 18, 21, 24, 27, 42, 45 $ .
- There are $ 9 $ integers satisfying only the second condition: $ 13, 23, 31, 32, 34, 35, 37, 38, 43 $ .
- There are no integers satisfying only the third condition.
### Sample Explanation 2
Below are examples of applicable integers.
- Integers satisfying only the first condition include $ 555 $ and $ 1011 $ .
- Integers satisfying only the second condition include $ 343 $ and $ 553 $ .
- Integers satisfying only the third condition include $ 1012 $ and $ 704 $ .
### Sample Explanation 3
There are no applicable integers.
### Constraints
- $ N $ is an integer.
- $ 1 \leq N < 10^{500} $