問題一覧 > 通常問題

No.319 happy b1rthday 2 me

レベル : / AI推定難易度 : 1650 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 66
作問者 : りあん
お気に入りにしたユーザー ProblemId : 850 / 自分の提出
問題文最終更新日: 2026-06-25 13:42:27
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
Advent Calendar Contest 2015 (順位表) の他の問題:

Note

This problem was created as the problem for day 12 of Advent Calendar Contest Advent Calendar 2015 and was published on December 12, 2015.

Please watch over it with lukewarm eyes.

Problem Statement

For positive integers $A, B(A \leq B)$, Rian-kun considered the string formed by concatenating the numbers from $A$ to $B$ in decimal notation, and decided to name it the "$(A,B)$ string".

For example, the "$(3,5)$ string" is "$345$", the "$(8,13)$ string" is "$8910111213$", and the "$(102,102)$ string" is "$102$".

Now Rian-kun has become curious about the number of contiguous substrings "$12$" contained in the "$(A,B)$ string" formed from given positive integers $A, B$.

Rian-kun, drunk from his first sip of booze, is in no state to do it, so please find in his place the number of "$12$" contained in the "$(A,B)$ string".

Input

$A$ $B$

The positive integers $A, \ B \ (1 \leq A \leq B \leq 12^{12} (= 8,916,100,448,256))$ that form the "$(A, B)$ string" are given on one line, separated by a space.

Output

Output the number of "$12$" contained in the "$(A,B)$ string" on one line.

Print a newline at the end.

Sample

Sample 1
Input
8 13
Output
1

This is the example shown in the problem statement. "$8910111213$" contains one "$12$".

Sample 2
Input
102 102
Output
0

The "$(102,102)$ string" is "$102$". Non-contiguous occurrences are not counted.

Sample 3
Input
19951212 20151212
Output
33124

Rian-kun was born on 1995/12/12 and turned 20 years old today.

Sample 4
Input
1212 121212121212
Output
15240281554

The answer may not fit in a 32-bit integer.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。