Two best friends Serozha and Gena play a game.

Initially there is one pile consisting of n stones on the table. During one move one pile should be taken and divided into an arbitrary number of piles consisting of a1 > a2 > ... > ak > 0 stones. The piles should meet the condition a1 - a2 = a2 - a3 = ... = ak - 1 - ak = 1. Naturally, the number of piles k should be no less than two.

The friends play in turns. The player who cannot make a move loses. Serozha makes the first move. Who will win if both players play in the optimal way?

Input

The single line contains a single integer n (1 ≤ n ≤ 105).

Output

If Serozha wins, print k, which represents the minimal number of piles into which he can split the initial one during the first move in order to win the game.

If Gena wins, print "-1" (without the quotes).

Examples

Input

3


Output

2


Input

6


Output

-1


Input

100


Output

8
import java.io.BufferedReader;

import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;

public class C73_div1 {

	static boolean test = false; // System.getProperty("JENS_TURBO") != null;

	public String str() throws IOException {
		if (test) {
			return reader.readLine();
		} else {
			return in.readLine();
		}
	}

	private int in() throws NumberFormatException, IOException {
		return Integer.valueOf(str());
	}

	private long lon() throws NumberFormatException, IOException {
		return Long.valueOf(str());
	}

	private int[] ints() throws Throwable {
		StringTokenizer st = new StringTokenizer(str());

		int[] res = new int[st.countTokens()];
		for (int i = 0; i < res.length; i++) {
			res[i] = Integer.parseInt(st.nextToken());
		}
		return res;
	}

	private long[] longs() throws Throwable {
		StringTokenizer st = new StringTokenizer(str());

		long[] res = new long[st.countTokens()];
		for (int i = 0; i < res.length; i++) {
			res[i] = Long.parseLong(st.nextToken());
		}
		return res;
	}

	private BigInteger[] bigs() throws Throwable {
		StringTokenizer st = new StringTokenizer(str());

		BigInteger[] res = new BigInteger[st.countTokens()];
		for (int i = 0; i < res.length; i++) {
			res[i] = new BigInteger(st.nextToken());
		}
		return res;
	}

	public static void main(String[] args) throws Throwable {
		new C73_div1().solve();
	}

	public C73_div1() throws Throwable {
		if (test) {
			reader = new BufferedReader(new FileReader(new File(testDataFile)));
		}
	}

	static InputStreamReader inp = new InputStreamReader(System.in);
	static BufferedReader in = new BufferedReader(inp);

	static PrintWriter writer = new PrintWriter(System.out);
	static String testDataFile = "testdata.txt";
	BufferedReader reader = null;

	int getseg(int l, int r) {
		return nimsum[r] ^ nimsum[l - 1];
	}

	int maxn = 100020;

	int[] nim = new int[maxn];
	int[] nimsum = new int[maxn];
	int[] minpile = new int[maxn];
	int[] arr = new int[maxn];

	private void solve() throws Throwable, IOException {

		int visid = 0;
		minpile[1] = -1;
		int a = 0, x = 0;
		for (int n = 2; n < maxn; n++) {
			visid++;
			minpile[n] = -1;
			for (int k = 2; k * k < 2 * n; k++) {
				if ((2 * n) % k > 0)
					continue;
				int c = 2 * n / k + 1 - k;
				if (c <= 0 || (c & 1) > 0)
					continue;

				a = c >> 1;
				x = getseg(a, a + k - 1);
				arr[x] = visid;
				if (x == 0 && minpile[n] == -1)
					minpile[n] = k;
			}
			int i = 0;
			for (i = 0; arr[i] == visid; i++);
			nim[n] = i;
			nimsum[n] = nimsum[n - 1] ^ nim[n];
		}
		System.out.println(minpile[in()]);
	}

	private double d(int row, int col, int y, int x) {
		double val = Math.pow(row - y, 2) + Math.pow(col - x, 2);
		return Math.sqrt(val);
	}
}