xin = []

while True:

    x = int(input())

    if x == 0:

        break

    xin += [x]

for i in xin:

    print(sum(map(int , list(str(i)))))
xin = []

while True:

    x = input()

    if x == '0':

        break

    xin += [x]

for i in xin:

    print(sum(map(int , list(i))))
xin = []
while True:
    x = int(input())
    if x == 0:
        break
    xin += [x]
for i in xin:
    print(sum(map(int, list(str(i)))))

xin = []
while True:
    x = input()
    if x == "0":
        break
    xin += [x]
for i in xin:
    print(sum(map(int, list(i))))

-    x = int(input()) -    if x == 0: +    x = input() +    if x == "0": -    print(sum(map(int, list(str(i))))) +    print(sum(map(int, list(i))))