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