n=input() x=n for _ in range(100): x=sum(map(int,x)) x=str(x) print(x)