def main(): print('428571'[int(input()) % 6]) if __name__ == '__main__': main()