N = int(input()) *S, = str(N) count = 1 while True: if N < 10 or count >= 100: break N = sum(map(int, S)) *S, = str(N) count += 1 print(N)