def f(a): ret=0 while a>0: ret+=a%10 a//=10 return ret N=int(input()) for i in range(99): N=f(N) print(N)