#include <bits/stdc++.h>
using namespace std;
struct S {
  int ini, tam, num;
  S() {}
  S(int I, int T, int N) { ini = I, tam = T, num = N; }
  bool operator<(const struct S &lhs) const { return num < lhs.num; }
} v[1000100];
int qtd;
int g[100100], ga[100100];
int mk[100100];
int calc(int a, int b) {
  if (a == 0) return g[b];
  return ga[b] ^ ga[a - 1];
}
int main() {
  for (int i = 1; i < 100001; ++i) {
    int j = i + 1, sum = i + i + 1;
    while (sum <= 100000) {
      v[qtd++] = S(i, j - i + 1, sum);
      j++;
      sum += j;
    }
  }
  sort(v, v + qtd);
  g[0] = g[1] = 0, ga[0] = ga[1] = 0;
  int pnt = 0;
  for (int i = 2; i < 100001; ++i) {
    while (v[pnt].num == i) {
      mk[calc(v[pnt].ini, v[pnt].ini + v[pnt].tam - 1)] = i;
      pnt++;
    }
    int q = 0;
    while (mk[q] == i) q++;
    g[i] = q;
    ga[i] = ga[i - 1] ^ q;
  }
  int n;
  scanf("%d", &n);
  int a = lower_bound(v, v + qtd, S(0, 0, n)) - v;
  int b = upper_bound(v, v + qtd, S(0, 0, n)) - v;
  int r = -1;
  for (int i = a; i < b; ++i) {
    if (calc(v[i].ini, v[i].ini + v[i].tam - 1) == 0) {
      if (r == -1)
        r = v[i].tam;
      else
        r = min(r, v[i].tam);
    }
  }
  printf("%d\n", r);
  return 0;
}
