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.*;
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.fill;
import static java.util.Arrays.binarySearch;
import static java.util.Arrays.sort;

public class Main {
	public static void main(String[] args) throws IOException {
		new Thread(null, new Runnable() {
			public void run() {
				try {
					try {
						if (new File("input.txt").exists())
							System.setIn(new FileInputStream("input.txt"));
					} catch (SecurityException e) {}
					new Main().run();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}, "1", 1L << 24).start(); 
	}

	BufferedReader in;
	PrintWriter out;
	StringTokenizer st = new StringTokenizer("");

	int MAX = 100000;
	int[] xor = new int [MAX + 1];
	int[] mex = new int [MAX + 1];
	
	void run() throws IOException {
		int[] tmp = new int [1000];
		for (int i = 1; i < mex.length; i++) {
			int sz = 0;
			int di = i << 1;
			for (int k = 2; k * k <= di; k++) {
				if (di % k == 0) {
					int g1 = get(di, k); if (g1 >= 0) tmp[sz++] = g1;
					int g2 = get(di, di / k); if (g2 >= 0) tmp[sz++] = g2;
				}
			}
			
			sort(tmp, 0, sz);

			if (sz == 0 || tmp[0] > 0) {
				mex[i] = 0;
			} else {
				boolean ok = false;
				for (int j = 1; j < sz; j++)
					if (tmp[j] - tmp[j - 1] > 1) {
						mex[i] = tmp[j - 1] + 1;
						ok = true;
						break;
					}
				if (!ok) mex[i] = tmp[sz - 1] + 1;
			}
			xor[i] = xor[i - 1] ^ mex[i];
		}
		
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		
		int n = nextInt();
		if (mex[n] == 0) {
			out.println(-1);
		} else {
			int dn = n << 1;
			for (int k = 2; ; k++) {
				if (dn % k == 0 && get(dn, k) == 0) {
					out.println(k);
					break;
				}
			}
		}
		
		out.close();
	}
	
	int get(int dn, int k) {
		int num = dn / k - k + 1;
		if ((num & 1) == 1) return -1;
		int af = num >> 1;
		if (af <= 0) return -1;
		int al = af + k - 1;
//		System.out.println(af + " " + al + " " + k + " " + dn / 2 + " " + (xor[al] ^ xor[af - 1]));
		return xor[al] ^ xor[af - 1];
	}

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

	/*************************************************************** 
	 * Input 
	 **************************************************************/
	String nextToken() throws IOException {
		while (!st.hasMoreTokens())
			st = new StringTokenizer(in.readLine());
		return st.nextToken();
	}
	
	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}
	
	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}
	
	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
	
	String nextLine() throws IOException {
		st = new StringTokenizer("");
		return in.readLine();
	}
	
	boolean EOF() throws IOException {
		while (!st.hasMoreTokens()) {
			String s = in.readLine();
			if (s == null)
				return true;
			st = new StringTokenizer(s);
		}
		return false;
	}
}
