from sys import stdin



for l in stdin:

    l = l.rstrip()

    if 0 == int(l):

        break



    print((sum([int(ch) for ch in l])))
def main():

    while True:

        num = eval(input())



        if num == "0":

            break



        print((sum([int(x) for x in num])))



if __name__ == '__main__':

    main()

from sys import stdin

for l in stdin:
    l = l.rstrip()
    if 0 == int(l):
        break
    print((sum([int(ch) for ch in l])))

def main():
    while True:
        num = eval(input())
        if num == "0":
            break
        print((sum([int(x) for x in num])))


if __name__ == "__main__":
    main()

-from sys import stdin +def main(): +    while True: +        num = eval(input()) +        if num == "0": +            break +        print((sum([int(x) for x in num]))) -for l in stdin: -    l = l.rstrip() -    if 0 == int(l): -        break -    print((sum([int(ch) for ch in l]))) + +if __name__ == "__main__": +    main()