NOI Contest Archive

Archive / 2022 / May 2022

2049

Easy · National Olympiad in Informatics Sri Lanka - May 2022

You are an archaeologist that comes across the Mayan Calendar. The Calendar is a continuous inscription of different characters of the Mayan Alphabet. The Mayan Language is difficult to decipher. However, all letters are directly mappable to the lowercase English alphabet and Arabic numerals from 0-9. You notice that the number ‘2049’ appears quite a few times within this inscription and are convinced it is linked to something significant. However, since the number by itself is meaningless, you want to recognize the number of substrings in the inscription which contain at least one instance of the number ‘2049’.

Note: Multiple occurences of the same substring are considered different.

Input Format

Output Format

Constraints

Sample Input 0

20492p049s

Sample Output 0

7

Sample Input 1

20492049

Sample Output 1

9