#include <bits/stdc++.h>
int sg[100010], f[100010], pre[100010];
int used[100010];
int n;
int cal(int n) {
  for (int m = 2;; m++) {
    int tot = m * (m - 1) / 2;
    if (tot > n) break;
    tot = n - tot;
    if (tot % m) continue;
    int s = tot / m;
    int t = s + m - 1;
    int v = sg[t] ^ sg[s - 1];
    used[v] = n;
    if (v == 0 && pre[n] == 0) pre[n] = m;
  }
  int ret = 0;
  for (; used[ret] == n; ret++)
    ;
  return ret;
}
int main() {
  int i, j, k;
  scanf("%d", &n);
  for (i = 3; i <= n; i++) {
    f[i] = cal(i);
    sg[i] = sg[i - 1] ^ f[i];
  }
  if (f[n])
    printf("%d\n", pre[n]);
  else
    puts("-1");
  return 0;
}
