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