#include <bits/stdc++.h>
using namespace std;
int n, g[100005], s[100005], b[100005], out;
int main() {
  scanf("%d", &n);
  memset(b, 0, sizeof(b));
  g[0] = s[0] = 0;
  g[1] = s[1] = 0;
  g[2] = s[2] = 0;
  for (int i = 3, k; i <= n; i++) {
    out = 100005;
    int x;
    k = (int)sqrt((double)i);
    for (int j = 1; j <= k; j++) {
      x = i / j;
      if (((j & 1) == 1) && (j > 1) && (j * x == i) && (x - j / 2 > 0)) {
        int temp = s[x + j / 2] ^ s[x - j / 2 - 1];
        b[temp] = i;
        if ((temp == 0) && (j < out)) out = j;
      }
      x = i / j;
      if (((x & 1) == 1) && (x > 1) && (x * j == i) && (j - x / 2 > 0)) {
        int temp = s[j + x / 2] ^ s[j - x / 2 - 1];
        b[temp] = i;
        if ((temp == 0) && (x < out)) out = x;
      }
    }
    k = (int)sqrt((double)2 * i);
    for (int j = 1; j <= k; j++) {
      x = (2 * i / j - 1) / 2;
      if (((j & 1) == 0) && (j > 1) && (j * (2 * x + 1) == 2 * i) &&
          (x - j / 2 >= 0)) {
        int temp = s[x + j / 2] ^ s[x - j / 2];
        b[temp] = i;
        if ((temp == 0) && (j < out)) out = j;
      }
      int J = (j - 1) / 2;
      x = 2 * i / (2 * J + 1);
      if (((x & 1) == 0) && (x > 1) && (x * (2 * J + 1) == 2 * i) &&
          (J - x / 2 >= 0)) {
        int temp = s[J + x / 2] ^ s[J - x / 2];
        b[temp] = i;
        if ((temp == 0) && (x < out)) out = x;
      }
    }
    for (int j = 0;; j++) {
      if (b[j] != i) {
        g[i] = j;
        s[i] = s[i - 1] ^ g[i];
        break;
      }
    }
  }
  if (g[n] == 0)
    printf("-1\n");
  else
    printf("%d\n", out);
  return 0;
}
