#B4283. Decomposing N into Three Distinct Positive Integers Without Forbidden Digits

    ID: 11940 Type: Default 1000ms 256MiB

Decomposing N into Three Distinct Positive Integers Without Forbidden Digits

Decomposing N into Three Distinct Positive Integers Without Forbidden Digits

Given a positive integer (N), decompose (N) into a sum of three distinct positive integers (a), (b), and (c) such that none of these integers contains the digits (3) or (7) in any of their decimal digits. In other words, for each integer in the decomposition, its string representation must not include the characters '3' or '7'.

Two decompositions are considered different if the sets ({a, b, c}) are different.

For example, if (N = 8), the possible decompositions (without considering the restrictions) are:
((1, 1, 6)), ((1, 2, 5)), ((1, 3, 4)), ((2, 2, 4)), ((2, 3, 3)).
Among these, only ((1, 2, 5)) is valid because it meets all the requirements (the three numbers are distinct and none contains a 3 or a 7).

inputFormat

The input consists of a single line containing one positive integer (N) ((1 \leq N \leq 10^4) or a reasonable bound based on the intended difficulty).

outputFormat

Output a single integer representing the number of valid decompositions of (N) into three distinct positive integers such that none of them contains the digit 3 or 7.

sample

8
1