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