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;

public class Main implements Runnable {
	private void solution() throws IOException {
		int n = in.nextInt();
		int[] grandy = new int[n + 1];
		int[] min = new int[n + 1];
		Arrays.fill(min, Integer.MAX_VALUE);
		Arrays.fill(grandy, -1);
		int res = doit(n, grandy, min);
		if (res == 0) {
			out.println(-1);
		} else {
			out.println(min[n]);
		}
	}

	private int doit(int n, int[] grandy, int[] min) {
		if (grandy[n] != -1) {
			return grandy[n];
		}
		Set<Integer> used = new HashSet<Integer>();
		for (int k = 2;; ++k) {
			int minValue = (1 + k) * k / 2;
			if (minValue > n) {
				break;
			}
			if ((n - minValue) % k == 0) {
				int add = (n - minValue) / k;
				int xor = 0;
				for (int i = 0; i < k; ++i) {
					xor ^= doit((i + 1) + add, grandy, min);
				}
				used.add(xor);
				if (xor == 0) {
					min[n] = Math.min(min[n], k);
				}
			}
		}
		for (int res = 0;; ++res) {
			if (!used.contains(res)) {
				return grandy[n] = res;
			}
		}
	}

	public void run() {
		try {
			// try {
			// String fileName = "";
			// in = new Scanner(new FileReader(fileName + ".in"));
			// out = new PrintWriter(fileName + ".out");
			// } catch (Exception e) {
			// }
			solution();
			in.reader.close();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	private static class Scanner {
		private BufferedReader reader;
		private StringTokenizer tokenizer;

		public Scanner(Reader reader) {
			this.reader = new BufferedReader(reader);
			this.tokenizer = new StringTokenizer("");
		}

		public boolean hasNext() throws IOException {
			while (!tokenizer.hasMoreTokens()) {
				String line = reader.readLine();
				if (line == null) {
					return false;
				}
				tokenizer = new StringTokenizer(line);
			}
			return true;
		}

		public String next() throws IOException {
			hasNext();
			return tokenizer.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			tokenizer = new StringTokenizer("");
			return reader.readLine();
		}

		public int[] nextInts(int n) throws IOException {
			int[] res = new int[n];
			for (int i = 0; i < n; ++i) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongs(int n) throws IOException {
			long[] res = new long[n];
			for (int i = 0; i < n; ++i) {
				res[i] = nextLong();
			}
			return res;
		}

		public double[] nextDoubles(int n) throws IOException {
			double[] res = new double[n];
			for (int i = 0; i < n; ++i) {
				res[i] = nextDouble();
			}
			return res;
		}

		public String[] nextStrings(int n) throws IOException {
			String[] res = new String[n];
			for (int i = 0; i < n; ++i) {
				res[i] = next();
			}
			return res;
		}
	}

	public static void main(String[] args) throws Exception {
		new Thread(null, new Main(), "Main", 1 << 28).start();
	}
	private Scanner in = new Scanner(new InputStreamReader(System.in));
	private PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
}
