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