N = int(input()) i = 1 def digitsum(n): ans = 0 for i in range(100): ans += (n // (10 ** i)) % 10 return ans while i < 100: N = digitsum(N) i += 1 print(N)