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