while True:

 S=input()

 if S=='0':break

 m=[1]+[0 for i in range(10)]

 d=A=0

 e=1

 S=reversed(S)

 for c in S:

  d=(d+int(c)*e)%11  

  if int(c)!=0:A+=m[d]

  m[d]+=1

  e*=-1

 print(A)

while True:

    S = input()[::-1]

    if S == '0' : break

    m = [1] + [0] * 10

    diff = ans = 0

    even = 1

    for c in S:

        num = int(c)

        diff = (diff + num * even) % 11

        if num : ans += m[diff]

        m[diff] += 1

        even *= -1

    print(ans)

while True:
    S = input()
    if S == "0":
        break
    m = [1] + [0 for i in range(10)]
    d = A = 0
    e = 1
    S = reversed(S)
    for c in S:
        d = (d + int(c) * e) % 11
        if int(c) != 0:
            A += m[d]
        m[d] += 1
        e *= -1
    print(A)

while True:
    S = input()[::-1]
    if S == "0":
        break
    m = [1] + [0] * 10
    diff = ans = 0
    even = 1
    for c in S:
        num = int(c)
        diff = (diff + num * even) % 11
        if num:
            ans += m[diff]
        m[diff] += 1
        even *= -1
    print(ans)

-    S = input() +    S = input()[::-1] -    m = [1] + [0 for i in range(10)] -    d = A = 0 -    e = 1 -    S = reversed(S) +    m = [1] + [0] * 10 +    diff = ans = 0 +    even = 1 -        d = (d + int(c) * e) % 11 -        if int(c) != 0: -            A += m[d] -        m[d] += 1 -        e *= -1 -    print(A) +        num = int(c) +        diff = (diff + num * even) % 11 +        if num: +            ans += m[diff] +        m[diff] += 1 +        even *= -1 +    print(ans)