n=int(input()) for i in range(100): s=[int(x) for x in str(n)] n=sum(s) print(n)