S = str(input()) for i in range(100): a = 0 for j in range(len(S)): n = int(S[j]) a += n S = str(a) print(a)