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.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class CF_Div1_73_C {

    static int INFINITY = 2000000000;
    static int num;
    static int min;
    static int[] dp;

    public static void main(String[] args) throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        sc = new StringTokenizer("");

        int n = nxtInt();
        num = n;
        dp = new int[n + 5];
        Arrays.fill(dp, -1);
        min = INFINITY;
        if (grundy(n) == 0) {
            System.out.println(-1);
        } else {
            System.out.println(min);
        }
    }// end Main.

    public static int grundy(int n) {

        if (dp[n] != -1)
            return dp[n];

        HashSet<Integer> set = new HashSet<Integer>();
        for (int k = 2; k < Math.sqrt(2 * n); k++) {
            double x = 2 * n - Math.pow(k, 2);
            double y = (double) x / k;
            y += 1;
            y /= 2;
            int a = (int) y;
            if (a == y) {
                int xorValue = 0;
                for (int j = 0; j < k; j++) {
                    xorValue ^= grundy(a + j);
                }// end for(j).
                if (xorValue == 0 && n == num) {
                    min = Math.min(min, k);
                }
                set.add(xorValue);
            }
        }// end for(k).

        int i = 0;
        while (set.contains(i))
            i++;
        return dp[n] = i;
    }

    static BufferedReader br;
    static StringTokenizer sc;
    static PrintWriter out;

    static String nxtTok() throws IOException {
        while (!sc.hasMoreTokens()) {
            String s = br.readLine();
            if (s == null)
                return null;
            sc = new StringTokenizer(s.trim());
        }
        return sc.nextToken();
    }

    static int nxtInt() throws IOException {
        return Integer.parseInt(nxtTok());
    }

    static long nxtLng() throws IOException {
        return Long.parseLong(nxtTok());
    }

    static double nxtDbl() throws IOException {
        return Double.parseDouble(nxtTok());
    }

    static int[] nxtIntArr(int n) throws IOException {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nxtInt();
        return a;
    }

    static long[] nxtLngArr(int n) throws IOException {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nxtLng();
        return a;
    }

    static char[] nxtCharArr() throws IOException {
        return nxtTok().toCharArray();
    }

}// end class
