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