c = "285714"
n = int(input())
print(c[(n-1)%6])