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