N = int(input()) print((N - 1) % 9 + 1)