N = int(input()) nums = "285714" i = N%6-1 if i==-1: i=6 print(nums[i])