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