QOJ.ac

QOJ

Time Limit: 3 s Memory Limit: 256 MB Total points: 10

#204. A + B

Statistics

Don't believe everything you see on TV! Bajtuś was recently channel surfing and saw a sight where someone incorrectly added two numbers in writing (image on the left):

This completely distorted his understanding of mathematics, and the poor boy now has trouble with the written addition of two numbers. Bajtuś writes them one under the other, right-aligned, and then at each position adds the two digits together (for example, $8 + 8 = 16$) and writes their sum directly below them in the result space. If there is only one digit at a position (because one number is shorter than the other), Bajtuś simply copies that digit to the result. The boy, of course, uses the decimal system. Above on the right, you can see two additional examples of calculations using this method.

One day, Bajtuś "added" two non-negative integers $a$ and $b$ in the manner described above and obtained the "sum" $n$. However, he accidentally spilled juice on the paper where he performed the operation, making the numbers $a$ and $b$ impossible to read! He is now wondering how many such ordered pairs of non-negative integers $(a, b)$ could have been written on the paper. Help him determine this!

Input

The first and only line of standard input contains a single integer $n$ ($1 \le n < 10^{18}$).

Output

The output should contain a single integer representing the number of ordered pairs of non-negative integers $(a, b)$ which, when "added" by Bajtuś, result in $n$.

Examples

Input 1

112

Output 1

50

Note

On Bajtuś's paper, there could have been one of the following 50 pairs of numbers: $(0, 112), (1, 111), (2, 110), (3, 19), (4, 18), (5, 17), (6, 16), (7, 15), (8, 14), (9, 13), (10, 102), (11, 101), (12, 100), (13, 9), (14, 8), (15, 7), (16, 6), (17, 5), (18, 4), (19, 3), (20, 92), (21, 91), (22, 90), (30, 82), (31, 81), (32, 80), (40, 72), (41, 71), (42, 70), (50, 62), (51, 61), (52, 60), (60, 52), (61, 51), (62, 50), (70, 42), (71, 41), (72, 40), (80, 32), (81, 31), (82, 30), (90, 22), (91, 21), (92, 20), (100, 12), (101, 11), (102, 10), (110, 2), (111, 1)$ and $(112, 0)$.

Note that, for example, the pairs $(3, 19)$ and $(19, 3)$ are counted separately because we are interested in ordered pairs.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.