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
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Saransh
 */
import java.io.*;
import java.util.*;
import java.math.*;
import java.lang.*;


public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        try
        {
            Parserdoubt pd=new Parserdoubt(System.in);
            PrintWriter pw=new PrintWriter(System.out);
            int grundies[]=new int[100001];
            int minimums[]=new int[100001];
            Arrays.fill(minimums,Integer.MAX_VALUE);
            //System.out.println(get(3,2));
            for(int i=3;i<=100000;i++)
            {
                int n=(int)(Math.ceil((-1+Math.sqrt(8*i))/2.0))+3;
                
                HashSet<Integer> set=new HashSet<Integer>();
                for(int j=2;j<=n;j++)
                {
                    int start=get(i,j);
                    
                    if(start>0)
                    {
                        int foset=0;
                        for(int k=0;k<j;k++)
                        {
                            foset^=grundies[k+start];
                        }
                        if(foset==0)
                        {
                            minimums[i]=Math.min(minimums[i], j);
                            
                        }
                        set.add(foset);
                    }
                }
                int chk=0;
                while(true)
                {
                    if(set.contains(chk))
                    {
                        chk++;
                    }
                    else
                    {
                        grundies[i]=chk;
                        break;
                    }
                }
            }
                
                int input=pd.nextInt();
                if(grundies[input]==0)
                    System.out.println(-1);
                else
                    System.out.println(minimums[input]);
            



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

    }
    public static int get(int sum,int terms)
    {
        if((2*sum)%terms!=0)
            return -1;
        int tmp=2*sum;
        tmp/=terms;
        tmp=tmp+1-terms;
        if(tmp<0||tmp%2==1)
            return -1;
        return tmp/2;



    }
    
}


class Parserdoubt
    {
       final private int BUFFER_SIZE = 1 << 17;

       private DataInputStream din;
       private byte[] buffer;
       private int bufferPointer, bytesRead;

       public Parserdoubt(InputStream in)
       {
          din = new DataInputStream(in);
          buffer = new byte[BUFFER_SIZE];
          bufferPointer = bytesRead = 0;
       }
       public String nextString() throws Exception
       {
           StringBuffer sb=new StringBuffer("");
           byte c = read();
           while (c <= ' ') c = read();
           do
           {
               sb.append((char)c);
               c=read();
           }while(c>' ');
           return sb.toString();
       }
       public char nextChar() throws Exception
       {
           byte c=read();
           while(c<=' ') c= read();
           return (char)c;
       }
       public int nextInt() throws Exception
       {
          int ret = 0;
          byte c = read();
          while (c <= ' ') c = read();
          boolean neg = c == '-';
          if (neg) c = read();
          do
          {
              ret = ret * 10 + c - '0';
             c = read();
          } while (c > ' ');
          if (neg) return -ret;
          return ret;
       }
       public long nextLong() throws Exception
       {
          long ret = 0;
          byte c = read();
          while (c <= ' ') c = read();
          boolean neg = c == '-';
          if (neg) c = read();
          do
          {
              ret = ret * 10 + c - '0';
             c = read();
          } while (c > ' ');
          if (neg) return -ret;
          return ret;
       }
       private void fillBuffer() throws Exception
       {
          bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
          if (bytesRead == -1) buffer[0] = -1;
       }

       private byte read() throws Exception
       {
          if (bufferPointer == bytesRead) fillBuffer();
          return buffer[bufferPointer++];
       }
    }