n=list(map(int,input())) for _ in range(100): sum_n=str(sum(n)) n=list(map(int,sum_n)) print(n[0])