import sys input=lambda:sys.stdin.readline().rstrip() def calc(N): ret=0 for i in N: ret+=int(i) return str(ret) N=input() for i in range(99): N=calc(N) print(N)