num = int(input()) % 9 if num == 0: print('9') else: print(num)