n = input() now = 0 for i in range(100): for j in n: now += int(j) n = str(now) now = 0 print(n)