# -*- coding: utf-8 -*-

while True:

 s = input()

 if s=="0": break

 t = 0

 for n in s:

  t += int(n)

 print(t)
while True:

 s = input()

 if s!="0": print(sum(map(int, s)))

 else: break
# -*- coding: utf-8 -*-
while True:
    s = input()
    if s == "0":
        break
    t = 0
    for n in s:
        t += int(n)
    print(t)

while True:
    s = input()
    if s != "0":
        print(sum(map(int, s)))
    else:
        break

-# -*- coding: utf-8 -*- -    if s == "0": +    if s != "0": +        print(sum(map(int, s))) +    else: -    t = 0 -    for n in s: -        t += int(n) -    print(t)