n = int(input()) pli = [2, 3] for i in range(6, n//2 + 1, 6): for p in pli: if i - 1 % p == 0: break else: pli.append(i - 1) for p in pli: if i + 1 % p == 0: break else: pli.append(i + 1) t = [] tn = n * (n + 1) // 2 for i in pli: while tn % i == 0: tn //= i t.append(i) if tn == 1: break li = [1] for i in t: for j in range(len(li)): if li[j] * i <= n: li.append(li[j] * i) li = list(set(li)) li.sort() print(li[len(li)-1])