def strsum(x): x = [int(num) for num in x] return str(sum(x)) N = input() for i in range(100): N = strsum(N) print(N)