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.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);

        }

    }
}

