n = int(input()) for i in range(99): n = sum(list(map(int, str(n)))) print(n)