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.util.*;
import java.io.*;
import java.math.BigInteger;
import static java.lang.Math.*;

public class Sol implements Runnable {
	ArrayList <Integer> divisors(int n) {
		ArrayList <Integer> ret = new ArrayList <Integer> ();
		for (int i = 1; i * i <= n; i++) {
			if (n % i == 0) {
				ret.add(i);
			}
			if (n % (n / i) == 0 && i * i != n) {
				ret.add(i);
			}
		}
		return ret;
	}

	void solve() throws Exception {
		int n = nextInt();
		int [] arr = new int[n + 1];
		int [] best = new int[n + 1];
		Arrays.fill(best, Integer.MAX_VALUE);
		for (int have = 3; have <= n; have++) {
			ArrayList <Integer> divs = divisors(2 * have);
			HashSet <Integer> trans = new HashSet <Integer> ();
			for (int k: divs) {
				if (k == 1) continue;
				int a2 = (2 * have) / k + 1 - k;
				if (a2 >= 1 && a2 % 2 == 0) {
					int a = a2 / 2;
					int xor = 0;
					for (int i = a; i < a + k; i++) {
						xor ^= arr[i];
					}
					if (xor == 0) {
						best[have] = min(best[have], k);
					}
					trans.add(xor);
				}	
			}
			for (int nres = 0; ; nres++) {
				if (!trans.contains(nres)) {
					arr[have] = nres;
					break;
				}
			}		
		}

		if (arr[n] == 0) {
			out.println(-1);
			return;
		}

		out.println(best[n]);
	}

	public static void main(String[] args) {
		new Thread(new Sol()).start();
	}

	public void run() {
		try {
			Locale.setDefault(Locale.US);
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			solve();

			out.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	
	StringTokenizer tokenizer = new StringTokenizer("");
	BufferedReader in;
	PrintWriter out;
	long time;

	void sTime() {
		time = System.currentTimeMillis();
	}

	long gTime() {
		return System.currentTimeMillis() - time;
	}

	void gMemory() {
		debug("Memory: " + (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1000 + " kb");
	}

	public void debug(Object o) {
		System.err.println(o);
	}
	
	boolean seekForToken() {
		while (!tokenizer.hasMoreTokens()) {
			String s = null;
			try {
				s = in.readLine();
			} catch (Exception e) {
				e.printStackTrace();
			}
			if (s == null)
				return false;
			tokenizer = new StringTokenizer(s);
		}
		return true;
	}

	String nextToken() {
		return seekForToken() ? tokenizer.nextToken() : null;
	}

	int nextInt() {
		return Integer.parseInt(nextToken());
	}

	long nextLong() {
		return Long.parseLong(nextToken());
	}

	double nextDouble() {
		return Double.parseDouble(nextToken());
	}

	BigInteger nextBig() {
		return new BigInteger(nextToken());
	}
}
