#include <bits/stdc++.h>
using namespace std;
const int MaxN = 100005, MaxL = 100, NA = -1;
int p[MaxN];
int v[MaxN];
int s[MaxN];
bool b[MaxL];
int n;
int main(void) {
  int k, q, r, t;
  memset(p, NA, sizeof(p));
  v[0] = s[0] = 0;
  for (n = 1; n < MaxN; n++) {
    memset(b, 0, sizeof(b));
    for (k = 2;; k++) {
      t = (k * (k + 1)) >> 1;
      if (n < t) break;
      q = (n - t) / k;
      if (q * k == n - t) {
        assert(q + k < n);
        assert(q >= 0);
        r = s[q + k] ^ s[q];
        if (p[n] == NA && r == 0) p[n] = k;
        assert(r < MaxL);
        b[r] = true;
      }
    }
    for (k = 0; k < MaxL; k++)
      if (!b[k]) break;
    assert(k < MaxL);
    v[n] = k;
    s[n] = s[n - 1] ^ v[n];
  }
  while (scanf(" %d", &n) != EOF) {
    printf("%d\n", p[n]);
  }
  return 0;
}
