# https://yukicoder.me/problems/no/1168 # stars : 1 def s(i): r = 0 for j in i: r = r + int(j) return str(r) N = input().strip() for i in range(99): N = s(N) print(N)