def main(): N = input() for _ in range(100): N = str(sum(list(map(int, N)))) print(N) if __name__ == "__main__": main()