n = int(input()) for i in range(99): x = str(n) c = sum([int(j) for j in x]) n = c print(n)