from collections import Counter



s = eval(input())

mod1 = 673

mod2 = 3



num1 = 0

num2 = 0

li1 = []

li2 = []

pw1 = 10

pw2 = 10

for i, e in enumerate(s, 1):

    num1 *= 10

    num1 += int(e)

    num1 %= mod1

    inv = pow(pw1, mod1 - 2, mod1)

    li1.append(num1 * inv % mod1)



    num2 *= 10

    num2 += int(e)

    num2 %= mod2

    inv = pow(pw2, mod2 - 2, mod2)

    li2.append(num2 * inv % mod2)



    pw1 *= 10

    pw1 %= mod1

    pw2 *= 10

    pw2 %= mod2



li = [0] + [10 * e1 + e2 for e1, e2 in zip(li1, li2)]

c = Counter(li)



ans = 0

for v in list(c.values()):

    ans += v * (v - 1) // 2



print(ans)

from collections import Counter





def f(mod):

    ret = [0]

    power = 1

    num = 0

    for i, e in enumerate(s, 1):

        num *= 10

        num += int(e)

        num %= mod



        power *= 10

        power %= mod

        inv = pow(power, mod - 2, mod)



        ret.append(num * inv % mod)



    return ret





s = eval(input())



mod3 = f(3)

mod673 = f(673)



li = [10 * e673 + e3 for e3, e673 in zip(mod3, mod673)]



c = Counter(li)

ans = 0

for v in list(c.values()):

    ans += v * (v - 1) // 2

print(ans)

from collections import Counter

s = eval(input())
mod1 = 673
mod2 = 3
num1 = 0
num2 = 0
li1 = []
li2 = []
pw1 = 10
pw2 = 10
for i, e in enumerate(s, 1):
    num1 *= 10
    num1 += int(e)
    num1 %= mod1
    inv = pow(pw1, mod1 - 2, mod1)
    li1.append(num1 * inv % mod1)
    num2 *= 10
    num2 += int(e)
    num2 %= mod2
    inv = pow(pw2, mod2 - 2, mod2)
    li2.append(num2 * inv % mod2)
    pw1 *= 10
    pw1 %= mod1
    pw2 *= 10
    pw2 %= mod2
li = [0] + [10 * e1 + e2 for e1, e2 in zip(li1, li2)]
c = Counter(li)
ans = 0
for v in list(c.values()):
    ans += v * (v - 1) // 2
print(ans)

from collections import Counter


def f(mod):
    ret = [0]
    power = 1
    num = 0
    for i, e in enumerate(s, 1):
        num *= 10
        num += int(e)
        num %= mod
        power *= 10
        power %= mod
        inv = pow(power, mod - 2, mod)
        ret.append(num * inv % mod)
    return ret


s = eval(input())
mod3 = f(3)
mod673 = f(673)
li = [10 * e673 + e3 for e3, e673 in zip(mod3, mod673)]
c = Counter(li)
ans = 0
for v in list(c.values()):
    ans += v * (v - 1) // 2
print(ans)

+ +def f(mod): +    ret = [0] +    power = 1 +    num = 0 +    for i, e in enumerate(s, 1): +        num *= 10 +        num += int(e) +        num %= mod +        power *= 10 +        power %= mod +        inv = pow(power, mod - 2, mod) +        ret.append(num * inv % mod) +    return ret + + -mod1 = 673 -mod2 = 3 -num1 = 0 -num2 = 0 -li1 = [] -li2 = [] -pw1 = 10 -pw2 = 10 -for i, e in enumerate(s, 1): -    num1 *= 10 -    num1 += int(e) -    num1 %= mod1 -    inv = pow(pw1, mod1 - 2, mod1) -    li1.append(num1 * inv % mod1) -    num2 *= 10 -    num2 += int(e) -    num2 %= mod2 -    inv = pow(pw2, mod2 - 2, mod2) -    li2.append(num2 * inv % mod2) -    pw1 *= 10 -    pw1 %= mod1 -    pw2 *= 10 -    pw2 %= mod2 -li = [0] + [10 * e1 + e2 for e1, e2 in zip(li1, li2)] +mod3 = f(3) +mod673 = f(673) +li = [10 * e673 + e3 for e3, e673 in zip(mod3, mod673)]