Did you know that in the past, even calculators were programmed in computer science classes?
The author of this problem personally learned about this from their parents, who did something similar in the late 1980s.
In 2026, the main trend is communicating with various LLM models in chat mode (and not only that).
But is it possible to communicate in a similar way with a chatbot programmed on a calculator?
It is possible if we consider some digits to be similar to letters of the Latin alphabet:
And if you turn the calculator upside down, you can see two more correspondences:
We will call a number $$$X$$$ a "word" if all of its digits are similar to letters:
Your task is to determine the number of word-like numbers in the interval $$$[0; N]$$$.
The only line contains one integer $$$N$$$ $$$(0 \le N \le 123456)$$$ — the upper bound of the interval $$$[0; N]$$$.
Print two integers $$$C_1$$$ and $$$C_2$$$ separated by a space:
34
8 15
8051
202 1100
123456
1536 10368
Example 1.
In the normal orientation, the following numbers look like words:
In the turned upside down orientation, the following numbers look like words:
Example 2.
This test is an additional opportunity to check that your counting is performed correctly.
Example 3.
This test checks that your counting is performed efficiently enough (the bound $$$N$$$ takes its maximum possible value).