n = int(input()) x = sum(list(map(int, str(n)))) for x in range(99): x = sum(list(map(int, str(n)))) print(x)