output_description: Print the number of pairs of integers (i,j) (1 ≤ i ≤ j ≤ |S|) that satisfy the
  condition.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      S
attempt: # python 3.8.2用
  import math
  import fractions
  import bisect
  import collections
  import itertools
  import heapq
  import string
  import sys
  import copy
  from decimal import *
  from collections import deque
  from math import gcd
  
  sys.setrecursionlimit(10**7)
  MOD = 10**9 + 7
  INF = float("inf")  # 無限大
  
  
  def lcm(a, b):
      return (a * b) // gcd(a, b)  # 最小公倍数
  
  
  def iin():
      return int(sys.stdin.readline())  # 整数読み込み
  
  
  def ifn():
      return float(sys.stdin.readline())  # 浮動小数点読み込み
  
  
  def isn():
      return sys.stdin.readline().split()  # 文字列読み込み
  
  
  def imn():
      return map(int, sys.stdin.readline().split())  # 整数map取得
  
  
  def imnn():
      return map(lambda x: int(x) - 1, sys.stdin.readline().split())  # 整数-1map取得
  
  
  def fmn():
      return map(float, sys.stdin.readline().split())  # 浮動小数点map取得
  
  
  def iln():
      return list(map(int, sys.stdin.readline().split()))  # 整数リスト取得
  
  
  def iln_s():
      return sorted(iln())  # 昇順の整数リスト取得
  
  
  def iln_r():
      return sorted(iln(), reverse=True)  # 降順の整数リスト取得
  
  
  def fln():
      return list(map(float, sys.stdin.readline().split()))  # 浮動小数点リスト取得
  
  
  def join(l, s=""):
      return s.join(l)  # リストを文字列に変換
  
  
  def perm(l, n):
      return itertools.permutations(l, n)  # 順列取得
  
  
  def perm_count(n, r):
      return math.factorial(n) // math.factorial(n - r)  # 順列の総数
  
  
  def comb(l, n):
      return itertools.combinations(l, n)  # 組み合わせ取得
  
  
  def two_distance(a, b, c, d):
      return ((c - a) ** 2 + (d - b) ** 2) ** 0.5  # 2点間の距離
  
  
  def m_add(a, b):
      return (a + b) % MOD
  
  
  def lprint(l):
      print(*l, sep="\n")
  
  
  S = input()
  
  MAX = 200000
  
  iv = 2019
  multiple = {}
  multiple[len(str(iv))] = set()
  multiple[len(str(iv))].add(str(iv))
  cnt = 2
  while True:
      tmp = iv * cnt
      if tmp <= MAX:
          if len(str(tmp)) not in multiple.keys():
              multiple[len(str(tmp))] = set()
          multiple[len(str(tmp))].add(str(tmp))
          cnt += 1
      else:
          break
  ans = 0
  
  for k, v in multiple.items():
      for i in range(len(S)):
          if i + k < len(S) + 1:
              if S[i : i + k] in v:
                  ans += 1
  print(ans)
  
problem_description: Statement
  
  Given is a string S consisting of digits from `1` through `9`.
  
  Find the number of pairs of integers (i,j) (1 ≤ i ≤ j ≤ |S|) that satisfy the
  following condition:
  
  Condition: In base ten, the i-th through j-th characters of S form an integer
  that is a multiple of 2019.
samples: [{"input": "1817181712114", "output": "3\n    \n\nThree pairs - (1,5), (5,9), and (9,13) \\- satisfy the condition.\n\n* * *"}, {"input": "14282668646", "output": "2\n    \n\n* * *"}, {"input": "2119", "output": "0\n    \n\nNo pairs satisfy the condition."}]