# coding utf-8 ans = [2,8,5,7,1,4] N = int(input()) N = int(N % 7) if N/7 == 0: N -= 1 print(ans[N])