def main(): print((int(input())-1) % 9+1) if __name__ == '__main__': main()