def mainProc(n): C_STR = '285714' print(C_STR[(n-1) % len(C_STR)]) if __name__ == '__main__': n = int(input()) mainProc(n)