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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.ArrayList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Sparsh Sanchorawala
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CInterestingGame solver = new CInterestingGame();
        solver.solve(1, in, out);
        out.close();
    }

    static class CInterestingGame {
        public void solve(int testNumber, InputReader s, PrintWriter w) {
            int n = s.nextInt();
            ArrayList<Pair>[] pair = new ArrayList[n + 1];
            for (int i = 1; i <= n; i++)
                pair[i] = new ArrayList<>();
            for (int k = 2; k <= n; k++)
                for (int a = 1; (long) (2 * a + k - 1) * k / 2 <= n; a++)
                    pair[(2 * a + k - 1) * k / 2].add(new Pair(a, k));
            int[] grundy = new int[n + 1];
            int[] val = new int[n + 1];
            Arrays.fill(val, Integer.MAX_VALUE);
            int[] pre = new int[n + 1];
            for (int i = 2; i <= n; i++) {
                HashSet<Integer> hs = new HashSet<>();
                for (Pair p : pair[i]) {
                    hs.add(pre[p.a + p.n - 1] ^ pre[p.a - 1]);
                    if ((pre[p.a + p.n - 1] ^ pre[p.a - 1]) == 0)
                        val[i] = Math.min(p.n, val[i]);
                }
                while (hs.contains(grundy[i]))
                    grundy[i]++;
                pre[i] = grundy[i] ^ pre[i - 1];
            }
            w.println(val[n] != Integer.MAX_VALUE ? val[n] : -1);
        }

        class Pair {
            int a;
            int n;

            Pair(int a, int n) {
                this.a = a;
                this.n = n;
            }

        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}

