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