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