N = int(input()) for _ in range(99): N = sum([int(a) for a in str(N)]) print(N)