N = input().strip() for i in range(100): N = str(sum([int(i) for i in N])) print(N)