N = input() a = N for i in range(2, 101): temp = 0 for aa in a: temp += int(aa) a = str(temp) print(a)