a = input() a = int(a) b = "285714"*a print(b[a-1])