#ABC164D. [ABC164D] Multiple of 2019

[ABC164D] Multiple of 2019

Score : 400400 points

Problem Statement

Given is a string SS consisting of digits from 1 through 9.

Find the number of pairs of integers (i,j)(i,j) (1ijS1 \leq i \leq j \leq |S|) that satisfy the following condition:

Condition: In base ten, the ii-th through jj-th characters of SS form an integer that is a multiple of 20192019.

Constraints

  • 1S2000001 \leq |S| \leq 200000
  • SS is a string consisting of digits from 1 through 9.

Input

Input is given from Standard Input in the following format:

SS

Output

Print the number of pairs of integers (i,j)(i,j) (1ijS1 \leq i \leq j \leq |S|) that satisfy the condition.

1817181712114
3

Three pairs - (1,5)(1,5), (5,9)(5,9), and (9,13)(9,13) - satisfy the condition.

14282668646
2
2119
0

No pairs satisfy the condition.