N=input() for _ in range(100): N=str(sum(int(n)for n in N)) print(N)