#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void read(T& x) {
  bool fu = 0;
  char c;
  for (c = getchar(); c <= 32; c = getchar())
    ;
  if (c == '-') fu = 1, c = getchar();
  for (x = 0; c > 32; c = getchar()) x = x * 10 + c - '0';
  if (fu) x = -x;
};
template <class T>
inline void read(T& x, T& y) {
  read(x);
  read(y);
}
template <class T>
inline void read(T& x, T& y, T& z) {
  read(x);
  read(y);
  read(z);
}
inline char getc() {
  char c;
  for (c = getchar(); c <= 32; c = getchar())
    ;
  return c;
}
int n, i, j, k, l, p, t;
int sg[100010], s[100010], g[100010];
int cnt[100010];
void calc(int k) {
  if (k <= 1) return;
  int zz = t / k - k + 1;
  if (zz % 2 != 0) return;
  zz /= 2;
  if (zz < 1) return;
  int tot = s[zz + k - 1] ^ s[zz - 1];
  if (tot == 0) g[i] = min(g[i], k);
  cnt[tot] = i;
}
int main() {
  read(n);
  memset(g, 127, sizeof(g));
  for (i = 3; i <= n; i++) {
    t = 2 * i;
    for (p = 1; p * p <= t; p++)
      if (t % p == 0) {
        calc(p);
        calc(t / p);
      }
    for (p = 0; cnt[p] == i; p++)
      ;
    sg[i] = p;
    s[i] = s[i - 1] ^ sg[i];
  }
  if (sg[n])
    printf("%d\n", g[n]);
  else
    printf("-1\n");
  scanf("\n");
  return 0;
}
