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