s = input().strip() n = 100 while n: r = 0 for c in s: r += int(c) s = str(r) n-=1 print(s)