import sys readline=sys.stdin.readline N=int(readline()) for _ in range(99): N=sum(map(int,list(str(N)))) print(N)