while 1:
	x = list(raw_input())
	if int(x[0]) == 0:
		break
	sum = 0
	for n in x:
		sum += int(n)
	print sum
9d1737b8b55d959e0998c20e41c7351c8ae199a1
while 1:
	x = list(raw_input())
	if int(x[0]) == 0:
		break
	sum = 0
	for n in x:
		sum += int(n)
	print sum