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

import java.lang.*;
import java.math.BigInteger;
import java.io.*;
import java.util.*;

public class Solution implements Runnable{
    public static BufferedReader br;
    public static PrintWriter out;
    public static StringTokenizer stk;
    public static boolean isStream = true;

    public static void main(String[] args) throws IOException {
    	if (isStream) {
            br = new BufferedReader(new InputStreamReader(System.in));
        } else {
            br = new BufferedReader(new FileReader("in.txt"));
        }
        out = new PrintWriter(System.out);
        new Thread(new Solution()).start();
    }

    public void loadLine() {
        try {
            stk = new StringTokenizer(br.readLine());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public String nextLine() {
        try {
            return br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
            return "";
        }
    }

    public String nextWord() {
        while (stk==null||!stk.hasMoreTokens()) loadLine();
        return stk.nextToken();
    }

    public Integer nextInt() {
        while (stk==null||!stk.hasMoreTokens()) loadLine();
        return Integer.valueOf(stk.nextToken());
    }

    public Long nextLong() {
        while (stk==null||!stk.hasMoreTokens()) loadLine();
        return Long.valueOf(stk.nextToken());
    }

    public Double nextDouble() {
        while (stk==null||!stk.hasMoreTokens()) loadLine();
        return Double.valueOf(stk.nextToken());
    }
    
    public Float nextFloat() {
        while (stk==null||!stk.hasMoreTokens()) loadLine();
        return Float.valueOf(stk.nextToken());
    }
    
    public void run() {
    	int n = nextInt();
        ArrayList<Integer>[] preA = new ArrayList[n+10];
        ArrayList<Integer>[] preB = new ArrayList[n+10];
    	boolean[] dp = new boolean[n+10];
    	int[] cnt = new int[n+10];
    	Arrays.fill(cnt, -1);
    	dp[0] = false;
    	cnt[0] = -1;
    	for (int i = 0; i <= n; i++) {
    		preA[i] = new ArrayList<Integer>();
    		preB[i] = new ArrayList<Integer>();
    	}
    	for (int i = 1; i <= n; i++) {
    		int sum = i;
    		for (int j = i+1; sum+j <= n; j++) {
    			sum += j;
    			preA[sum].add(i);
    			preB[sum].add(j);
    		}
    	}
    	
    	for (int i = 1; i <= n; i++) {
    		boolean ff = false;
    		int cc = -1;
			for (int pp = 0; pp < preA[i].size(); pp++) {
    			boolean f = false;
    			int a = preA[i].get(pp);
    			int b = preB[i].get(pp);
    			for (int k = a; k <= b; k++) {
    				f ^= dp[k];
    			}
    			if (!f) {
    				ff = true;
    				cc = b - a + 1;
    				break;
    			}
    		}
    		if (ff) {
    			dp[i] = true;
    			cnt[i] = cc;
    		} else {
    			dp[i] = false;
    			cnt[i] = -1;
    		}
    	}
    	out.println(cnt[n]);
    	out.flush();
    }
}
