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.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashSet;
import java.util.StringTokenizer;


public class Abood2D {
	
	static int n, min[], G[], pG[];
	
	static int solve(int c) {
		if(G[c] != -1)
			return G[c];
		
		HashSet<Integer> set = new HashSet<>();
		
		min[c] = c;
		
		for (int i = 2, j = 3; j <= c; j += ++i) 
			if((c - j) % i == 0) {
				int l = 1 + (c - j) / i;
				int r = i + (c - j) / i;
				
				int x = pG[r] ^ pG[l - 1];
				
				if(x == 0)
					min[c] = Math.min(min[c], i);
				
				set.add(x);
			}
		
		int ans = 0;
		while(set.contains(ans))ans++;
		
		return G[c] = ans;
		
	}
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		
		n = sc.nextInt();
		
		G = new int[(int) 1e6 + 1];
		pG = new int[(int) 1e6 + 1];
		min = new int[(int) 1e6 + 1];
		
		Arrays.fill(G, -1);
		
		for (int i = 1; i <= n; i++) 
			pG[i] = pG[i - 1] ^ solve(i);
		
		if(G[n] != 0)
			out.println(min[n]);
		else
			out.println(-1);
		
		out.flush();

	}



	static class Scanner 



	{
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

		public String next() throws IOException 
		{
			while (st == null || !st.hasMoreTokens()) 
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

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

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

		public String nextLine() throws IOException {return br.readLine();}


		public double nextDouble() throws IOException
		{
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if(x.charAt(0) == '-')
			{
				neg = true;
				start++;
			}
			for(int i = start; i < x.length(); i++)
				if(x.charAt(i) == '.')
				{
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				}
				else
				{
					sb.append(x.charAt(i));
					if(dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg?-1:1);
		}

		public boolean ready() throws IOException {return br.ready();}



	}


}