def f(x): s = str(x) v = 0 for i in s: v += int(i) return v N = int(input()) for _ in range(100): N = f(N) print(N)