a = '428571' n = int(input()) print(a[n % 6])