n = input() cnt = 1 while 1: if cnt == 100: print(n) break if len(n) == 1: print(n) break tot = 0 for i in n: tot += int(i) n = str(tot) cnt += 1