#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int grundy[N];
int best[N];
int n, mx;
int solve(int n) {
  if (n == 0) return 0;
  if (grundy[n] != -1) return grundy[n];
  bool block[20];
  memset(block, false, sizeof(block));
  for (int i = 2; i <= n; i++) {
    int r = n;
    int p = (i * (i - 1)) / 2;
    if (n < p) break;
    r -= p;
    if (r == 0) continue;
    if (r % i) continue;
    int b = 0;
    for (int j = (r / i); j < (r / i) + i; j++) {
      int tmp = solve(j);
      b ^= tmp;
    }
    block[b] = true;
    if (!best[n] and b == 0) best[n] = i;
  }
  for (int i = 0; i < 20; i++) {
    if (!block[i]) return grundy[n] = i;
  }
}
int main() {
  memset(grundy, -1, sizeof(grundy));
  scanf("%d", &n);
  solve(n);
  if (!solve(n)) {
    puts("-1");
  } else {
    printf("%d\n", best[n]);
  }
}
