if __name__ == '__main__': n = int(input()) f = '285714' print(int(f[(n % 6) -1]))