#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
int sg[N], sum[N], minn[N], vis[N];
void init_sg() {
  sg[0] = sg[1] = sg[2] = 0;
  sum[0] = sum[1] = sum[2] = 0;
  memset(minn, 0x3f, sizeof(minn));
  for (int n = 3; n <= 100000; n++) {
    int t = 2 * n;
    int factor = (int)(sqrt(t + 0.5));
    for (int k = 2; k <= factor; k++) {
      if (t % k == 0 && t / k + 1 - k > 0 && !((t / k + 1 - k) & 1)) {
        int a = (t / k + 1 - k) / 2;
        int p = sum[a + k - 1] ^ sum[a - 1];
        vis[p] = n;
        if (p == 0) minn[n] = min(minn[n], k);
      }
    }
    int v = 0;
    while (1) {
      if (vis[v] != n) {
        sg[n] = v;
        break;
      }
      v++;
    }
    sum[n] = sum[n - 1] ^ sg[n];
  }
}
int main() {
  init_sg();
  int n;
  while (scanf("%d", &n) == 1) {
    if (!sg[n]) {
      puts("-1");
      continue;
    }
    printf("%d\n", minn[n]);
  }
  return 0;
}
