def F(x): res = sum(int(i) for i in str(x)) return res N = int(input()) for _ in range(100): N = F(N) print(N)