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