import sys



for line in sys.stdin:

    if int(line) == 0: break

    s = 0

    for c in line.strip('\n'):

        s += '0123456789'.index(c)

    print(s)
while True:

    x = input()

    if x == '0':break

    print(sum(['0123456789'.index(c) for c in x]))
import sys

for line in sys.stdin:
    if int(line) == 0:
        break
    s = 0
    for c in line.strip("\n"):
        s += "0123456789".index(c)
    print(s)

while True:
    x = input()
    if x == "0":
        break
    print(sum(["0123456789".index(c) for c in x]))

-import sys - -for line in sys.stdin: -    if int(line) == 0: +while True: +    x = input() +    if x == "0": -    s = 0 -    for c in line.strip("\n"): -        s += "0123456789".index(c) -    print(s) +    print(sum(["0123456789".index(c) for c in x]))