N = list(input()) for _ in range(100): X = 0 for n in N: X += int(n) N = list(str(X)) print(X)