x = input()
x = str(x)

counter = 0
for i in x:
    counter += int(i)
print counter

while counter >= 1:
    if counter < 10:
        break
    else:
        counter = str(counter)
        second_count = 0
        for i in counter:
            second_count += int(i)

        print second_count
        counter = second_count

df60925183bb38230ae9e05cc346e5840e4f7f57
x = input()
x = str(x)

counter = 0
for i in x:
    counter += int(i)
print counter

while counter >= 1:
    if counter < 10:
        break
    else:
        counter = str(counter)
        second_count = 0
        for i in counter:
            second_count += int(i)

        print second_count
        counter = second_count
