56
 1
 46
 63478
 7578
 56056
 78
 66873
 8149
 35708
 81207
 41385
 37317
 74424
 67817
 684
 15
 96992
 38798
 19715
 627
 39509
 45899
 31893
 1515
 33
 95298
 27443
 60879
 99
 34378
 57113
 36655
 63359
 873
 67341
 100000
 42863
 35
 250
 573
 23
 871
 15748
 92763
 9564
 42602
 38
 42237
 70878
 93764
 303

-1
 -1
 4
 -1
 3
 -1
 4
 2
 2
 -1
 6
 15
 -1
 21
 73
 -1
 2
 -1
 76
 -1
 2
 -1
 -1
 3
 2
 2
 4
 2
 2
 2
 -1
 2
 -1
 34
 18
 2
 -1
 -1
 -1
 5
 3
 -1
 -1
 8
 22
 3
 17
 -1
 18
 -1
 -1
 2

/*
 * 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++];
       }
    }