a = '285714' p = int(input()) % 6 print(a[p - 1] if p != 0 else a[6])