from functools import reduce
while 1:

    n = input()

    if n == '0': break;

    print(reduce(lambda x,y: x+int(y), n, 0))
while 1:

    x = input()

    if x == '0': break;

    print(sum([int(d) for d in x]))
from functools import reduce

while 1:
    n = input()
    if n == "0":
        break
    print(reduce(lambda x, y: x + int(y), n, 0))

while 1:
    x = input()
    if x == "0":
        break
    print(sum([int(d) for d in x]))

-from functools import reduce - -    n = input() -    if n == "0": +    x = input() +    if x == "0": -    print(reduce(lambda x, y: x + int(y), n, 0)) +    print(sum([int(d) for d in x]))