题目描述
Problem Description
Punch-kun loves the number $7$ very much. Recently, he released a game related to the number seven and is successfully increasing the number of users.
Now, Punch-kun is interested in multiples of $7$. He came up with the following game:
Punch-kun and Nicole-chan have plenty of cards with the numbers $1$ to $7$. First, Punch-kun arranges some cards to form a natural number. Then, Nicole-chan arranges some cards to form a natural number that satisfies the following conditions:
- The number formed by Nicole-chan is less than or equal to the number formed by Punch-kun.
- The number formed by Nicole-chan is a multiple of $7$ in decimal notation.
How many different numbers can Nicole-chan form?
Input Format
The input is given from the standard input in the following format:
$ N $
- The first line contains the natural number $ N $ formed by Punch-kun, where $1 \leq N < 1000000000000000000$ (i.e., $ 10^{18} $).
- It is guaranteed that each digit of $ N $ is one of $\{1, 2, 3, 4, 5, 6, 7\}$.
Output Format
Output the number of different numbers that Nicole-chan can form in one line. Include a newline at the end of the output.
Sample Input and Output
Sample Input #1
31
Sample Output #1
3
Sample Input #2
7
Sample Output #2
1
Sample Input #3
111
Sample Output #3
8
Sample Input #4
777777777777777777
Sample Output #4
271402266318408
Notes/Hints
Partial Points
If you correctly solve the test cases where $1 \leq N < 100000$ (i.e., $ 10^5 $), you will be awarded 40 points as partial credit.
Sample Explanation 1
The numbers that Nicole-chan can form are $ 7, 14, 21 $. Note that $ 28 $ cannot be formed.
Sample Explanation 3
Since they have plenty of cards, Nicole-chan can also form numbers like $ 77 $ by arranging the same number.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分