#include <bits/stdc++.h>
using namespace std;
inline int SG(double x) { return x > -1E-8 ? x < 1E-8 ? 0 : 1 : -1; }
int tb[100011];
int c[100011];
int xc[100011];
int main() {
  int n, i, j, k, d, s, a, b, x;
  scanf("%d", &n);
  s = 0;
  xc[0] = 0;
  for (i = 1; i <= n; i++) {
    for (j = 2;; j++) {
      d = i * 2 - j * j + j;
      if (d <= 0) break;
      if (d % (j * 2) == 0) {
        a = d / (j * 2);
        b = a + j - 1;
        x = xc[b] ^ xc[a - 1];
        tb[x] = i;
      }
    }
    for (j = 0; tb[j] == i; j++)
      ;
    c[i] = j;
    xc[i] = xc[i - 1] ^ c[i];
  }
  if (c[n]) {
    for (j = 2;; j++) {
      d = n * 2 - j * j + j;
      if (d % (j * 2) == 0) {
        a = d / (j * 2);
        b = a + j - 1;
        x = xc[b] ^ xc[a - 1];
        if (!x) break;
      }
    }
    printf("%d\n", j);
  } else {
    puts("-1");
  }
  return 0;
}
