N = input() while len(N) != 1: res = 0 for n in N: res += int(n) N = str(res) print(N)