N=int(input()) for _ in range(100): tmp=0 for s in str(N): tmp+=int(s) N=tmp print(N)