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