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