Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())
s.reverse()
n = len(s)
now = 0
mods = [0] * 2019
mods[0] += 1
for i in range(n):
    now += pow(10, i) * int(s[i])
    now %= 2019
    mods[now] += 1
ans = 0
for i in mods:
    ans += (i * (i - 1)) // 2
print(ans)


Fixed submission:
if __name__ == '__main__':

    s = list(input())
    s.reverse()
    n = len(s)
    now = 0
    mods = [0] * 2019
    mods[0] += 1
    ten = 1
    for i in range(n):
        now += ten * int(s[i])
        now %= 2019
        ten *= 10
        ten %= 2019
        mods[now] += 1
    ans = 0
    for i in mods:
        ans += (i * (i - 1)) // 2
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())
s.reverse()
n = len(s)
now = 0
mods = [0] * 2019
mods[0] += 1
for i in range(n):
    now += pow(10, i) * int(s[i])
    now %= 2019
    mods[now] += 1
ans = 0
for i in mods:
    ans += (i * (i - 1)) // 2
print(ans)


Fixed submission:
if __name__ == '__main__':

    s = list(input())
    s.reverse()
    n = len(s)
    now = 0
    mods = [0] * 2019
    mods[0] += 1
    ten = 1
    for i in range(n):
        now += ten * int(s[i])
        now %= 2019
        ten *= 10
        ten %= 2019
        mods[now] += 1
    ans = 0
    for i in mods:
        ans += (i * (i - 1)) // 2
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())
s.reverse()
n = len(s)
now = 0
mods = [0] * 2019
for i in range(n):
    now += (10 ** i) * int(s[i])
    now %= 2019
    mods[now] += 1
ans = mods[0]
for i in mods:
    ans += (i * (i - 1)) // 2
print(ans)


Fixed submission:
if __name__ == '__main__':

    s = list(input())
    s.reverse()
    n = len(s)
    now = 0
    mods = [0] * 2019
    mods[0] += 1
    ten = 1
    for i in range(n):
        now += ten * int(s[i])
        now %= 2019
        ten *= 10
        ten %= 2019
        mods[now] += 1
    ans = 0
    for i in mods:
        ans += (i * (i - 1)) // 2
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())
s.reverse()
n = len(s)
now = 0
mods = [0] * 2019
for i in range(n):
    now += (10 ** i) * int(s[i])
    mods[now % 2019] += 1
ans = mods[0]
for i in mods:
    ans += (i * (i - 1)) // 2
print(ans)


Fixed submission:
if __name__ == '__main__':

    s = list(input())
    s.reverse()
    n = len(s)
    now = 0
    mods = [0] * 2019
    mods[0] += 1
    ten = 1
    for i in range(n):
        now += ten * int(s[i])
        now %= 2019
        ten *= 10
        ten %= 2019
        mods[now] += 1
    ans = 0
    for i in mods:
        ans += (i * (i - 1)) // 2
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
if __name__ == '__main__':
    s = list(input())
    s.reverse()
    n = len(s)
    now = 0
    mods = [0] * 2019
    for i in range(n):
        now += (10 ** i) * int(s[i])
        mods[now % 2019] += 1
    ans = mods[0]
    for i in mods:
        ans += (i * (i - 1)) // 2
    print(ans)


Fixed submission:
if __name__ == '__main__':

    s = list(input())
    s.reverse()
    n = len(s)
    now = 0
    mods = [0] * 2019
    mods[0] += 1
    ten = 1
    for i in range(n):
        now += ten * int(s[i])
        now %= 2019
        ten *= 10
        ten %= 2019
        mods[now] += 1
    ans = 0
    for i in mods:
        ans += (i * (i - 1)) // 2
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

if __name__ == '__main__':
    s = list(input())
    s.reverse()
    n = len(s)
    now = 0
    mods = [0] * n
    for i in range(n):
        now += (10 ** i) * int(s[i])
        mods[i] = now % 2019
    mods.sort()
    m = Counter(mods)
    ans = 0
    for k, v in m.items():
        if k == 0:
            ans += v
        ans += (v * (v - 1)) // 2
    print(ans)


Fixed submission:
if __name__ == '__main__':

    s = list(input())
    s.reverse()
    n = len(s)
    now = 0
    mods = [0] * 2019
    mods[0] += 1
    ten = 1
    for i in range(n):
        now += ten * int(s[i])
        now %= 2019
        ten *= 10
        ten %= 2019
        mods[now] += 1
    ans = 0
    for i in mods:
        ans += (i * (i - 1)) // 2
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

if __name__ == '__main__':
    s = list(input())
    n = len(s)
    mods = [0] * n
    for i in range(n - 1, -1, -1):
        mods[i] = int(''.join(s[i:])) % 2019
    mods.sort()
    m = Counter(mods)
    ans = 0
    for k, v in m.items():
        if k == 0:
            ans += v
        ans += (v * (v - 1)) // 2
    print(ans)


Fixed submission:
if __name__ == '__main__':

    s = list(input())
    s.reverse()
    n = len(s)
    now = 0
    mods = [0] * 2019
    mods[0] += 1
    ten = 1
    for i in range(n):
        now += ten * int(s[i])
        now %= 2019
        ten *= 10
        ten %= 2019
        mods[now] += 1
    ans = 0
    for i in mods:
        ans += (i * (i - 1)) // 2
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

if __name__ == '__main__':
    s = list(input())
    n = len(s)
    mods = [0] * n
    for i in range(n - 1, -1, -1):
        mods[i] = int(''.join(s[i:])) % 2019
    mods.sort()
    m = Counter(mods)
    ans = 0
    for k, v in m.items():
        if k == 0:
            ans += v
        ans += (v * (v - 1)) // 2
    print(ans)


Fixed submission:
if __name__ == '__main__':

    s = list(input())
    s.reverse()
    n = len(s)
    now = 0
    mods = [0] * 2019
    mods[0] += 1
    ten = 1
    for i in range(n):
        now += ten * int(s[i])
        now %= 2019
        ten *= 10
        ten %= 2019
        mods[now] += 1
    ans = 0
    for i in mods:
        ans += (i * (i - 1)) // 2
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

if __name__ == '__main__':
    s = list(input())
    s.reverse()
    n = len(s)
    mods = [0] * n
    for i in range(n):
        mods[i] = int(''.join(list(reversed(s[:i + 1])))) % 2019
    mods.sort()
    m = Counter(mods)
    ans = 0
    for k, v in m.items():
        if k == 0:
            ans += v
        ans += (v * (v - 1)) // 2
    print(ans)


Fixed submission:
if __name__ == '__main__':

    s = list(input())
    s.reverse()
    n = len(s)
    now = 0
    mods = [0] * 2019
    mods[0] += 1
    ten = 1
    for i in range(n):
        now += ten * int(s[i])
        now %= 2019
        ten *= 10
        ten %= 2019
        mods[now] += 1
    ans = 0
    for i in mods:
        ans += (i * (i - 1)) // 2
    print(ans)