Fruitful cooperation
InterviewTime limit1sMemory limit1024 MB
Given N up to 10^16, count the closed regions formed in the digits when all numbers from 1 to N are written in a row.
- Level
Medium5 of 10
- Topics
- Dynamic programming, Math
- Solved
- No attempts yet
Statement
This university has an odd atmosphere. Instead of helping each other and enjoying a sweet life, students constantly argue, put sticks in each other's wheels, and refuse to cooperate.
But Misha and Volodya are different. During a lecture on an incredibly interesting subject, Misha wrote all numbers from 1 to in a row. He wrote each digit carefully, as shown in the picture:

Closed regions formed in his notebook right away. For example, if , one closed region formed inside the digit 6. Volodya decided to help his friend pass the time by coloring every closed region. He wondered whether he could color all of them before the lecture ends. How many regions must he color?
Input
You are given one natural number ().
Output
Print one number: the number of regions Volodya must color.