def dig(k): s = str(k) ret = 0 for i in s: ret += int(i) return ret N = int(input()) for i in range(100): N = dig(N) print (N)