ר

11 http:\olimp.bstu.by
17
9:00 12:00

 
HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Sections > Unsorted > problem:


Kovrov

Section problems

• Polygons
• String manipulations
• Lawyers Council
• Math and Soldiers
• Many-coloured roads
• What about judges?
• Liars and Knights
• Interesting permutations
• Kovrov
• Points
• Roads
• Brackets
• Triangles
• String Multiplication
• Nice Floor
• Strange Numbers
• Factorial

Feedback

If you notice incorrect translations in Contester, please let author know.

Time limit 2000/4000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb.
: , .

Kovrov celebrates its anniversary at 1st September, because in 1778 in that day empress Catherine the Great issued the decree about foundation of Kovrov district and the town itself.

In this problem you have to find amount of all positive numbers between 1 and N such that they contain at least one '1' digit, two '7' digits and one '8' digit in decimal notation. I.e. you can get enough digits from the number to write down 1778.

Input
The first line contains a single number N (1 ≤ N ≤ 1000000).
Output
Output a single integer number - the answer for the problem.

Input 1 Output 1
1000
0
Input 2 Output 2
5000
3

.

www.contester.ru