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 java.math.*;


public class Solution
{   

   PrintWriter out;
   BufferedReader in;
   StringTokenizer ss;


   void dbg(String s){System.out.println(s);};
   void deb(String s){System.out.println(s);};
//   void deb(Object... s){System.out.println(s.toString());};

   String _token() throws IOException
   {
    while (!ss.hasMoreTokens())ss=new StringTokenizer(in.readLine());
    return ss.nextToken();
   }

   Double _double() throws IOException
   {
    return Double.parseDouble (_token());
   }

   int _int() throws IOException
   {
    return Integer.parseInt (_token());
   }

   long _long() throws IOException
   {
    return Long.parseLong (_token());
   }


  int N =(int)1e6;

  int best[] = new int[N];
  int val[] = new int[N];

  int fun(int n, int k)
  {
//    deb(n+" "+k);
    n*=2;

    if (k==1)
      return n+1;
  
    int a = (n/k)+k-1;
    if (a%2==1)
      return n+1;
    a/=2;
    if (a<k)
      return n+1;
    
//    deb(a+" "+n+" "+k);

    int ans=0;
    for(int i=0;i<k;i++)
      ans^=gr(a-i);
    return ans;
  }

  int gr(int n)
  {     
//    deb(n+"");

    if (val[n]!=-1)
      return val[n];
  
    boolean was[] = new boolean [2*n+2];
    for(int i=1;i*i<=2*n;i++)
    {
      if ((2*n)%i==0)
      {
        was[fun(n,i)]=true;
        was[fun(n,(2*n)/i)]=true;
      }
    }
    int j=0;
    while(was[j])
      j++;
    return val[n]=j;
  }

   
  void run()throws IOException
  {
    in = new BufferedReader(new InputStreamReader(System.in));
    out = new PrintWriter(System.out);
    ss = new StringTokenizer("  ");

    int n;

    for(int i=0;i<N;i++)
      val[i]=-1;

    n=_int();
    if(gr(n)==0)
       out.println(-1);
    else
    {  
      for(int k=2;k<=2*n;k++) 
        if ((2*n)%k==0)
        if (fun(n,k)==0)
        {
          out.println(k);
          out.close();
          return;
         }
     }
     out.close();
  }




  public static void main(String[] args)throws Exception{
     new Solution().run();
  }

   BigInteger add(BigInteger A, BigInteger B){return A.add(B);}
   BigInteger mult(BigInteger A, BigInteger B){return A.multiply(B);}
   BigInteger sub(BigInteger A, BigInteger B){return A.subtract(B);}
   BigInteger div(BigInteger A, BigInteger B){return A.divide(B);}
   BigInteger mi(BigInteger A){return (BigInteger.ZERO).subtract(A);}
   BigInteger sq(BigInteger A){return A.multiply(A);}
   BigInteger val(long a){return BigInteger.valueOf(a);}
   int cmp(BigInteger a, BigInteger b){return a.compareTo(b);}
}