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.math.*;
import java.util.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

public class CF33C {

    public static void main(String[] args) throws Exception {
//      for (int xx = 100000; xx <= 100000; xx++) 
        {

            int n = nextInt();
            ArrayList<Integer[]>[] allSums = new ArrayList[n + 1];
            for (int k = 0; k < allSums.length; k++) {
                allSums[k] = new ArrayList<Integer[]>();
            }
            for (long i = 1; i * 2 + 1 <= n; i++) {
                for (long j = i + 1;; j++) {
                    long s = sum(i, j);
                    if (s > n) {
                        break;
                    }
                    allSums[(int) s].add(new Integer[]
                        { (int) i, (int) j });
                }
            }
            int[] wins = new int[n + 1];
            int[] winSum = new int[n + 1];
            int[] ans = new int[n + 1];
            fill(ans, 1 << 30);
            ans[0] = 0;
            if (1 < ans.length) {
                ans[1] = 0;
            }
            if (2 < ans.length) {
                ans[2] = 0;
            }
            if (3 < ans.length) {
                ans[3] = 2;
                wins[3] = 1;
                winSum[3] = 1;
            }
            for (int i = 4; i < wins.length; i++) {
                for (Integer[] sums : allSums[i]) {
                    int beg = sums[0];
                    int end = sums[1];
                    int winsInRange = winSum[end] - winSum[beg - 1];
                    if (winsInRange % 2 == 0) {
                        ans[i] = min(ans[i], end - beg + 1);
                        wins[i] |= 1;
                    }
                }
                winSum[i] = winSum[i - 1] + wins[i];
                if (ans[i] == 1 << 30)
                    ans[i] = -1;
            }
            System.out.println(ans[n]);
        }
    }

    static long sum(long a, long b) {
        return sum(b) - sum(a - 1);
    }

    static long sum(long x) {
        return x * (x + 1) / 2;
    }

    static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    static StringTokenizer st = new StringTokenizer("");

    static String next() throws Exception {
        while (!st.hasMoreTokens()) {
            String s = in.readLine();
            if (s == null)
                return null;
            st = new StringTokenizer(s);
        }
        return st.nextToken();
    }

    static int nextInt() throws Exception {
        return Integer.parseInt(next());
    }

    static long nextLong() throws Exception {
        return Long.parseLong(next());
    }

    static double nextDouble() throws Exception {
        return Double.parseDouble(next());
    }

    static void DBG(Object... objects) {
        System.err.println(deepToString(objects));
    }

    static int RAND(int from, int to) {
        return (int) (random() * (to - from + 1)) + from;
    }

}
