#include <bits/stdc++.h>
using namespace std;
int getint() {
  unsigned int c;
  int x = 0;
  while (((c = getchar()) - '0') >= 10) {
    if (c == '-') return -getint();
    if (!~c) exit(0);
  }
  do {
    x = (x << 3) + (x << 1) + (c - '0');
  } while (((c = getchar()) - '0') < 10);
  return x;
}
const int N = 100111;
vector<pair<int, int> > divide[N];
int cache[N], pile[N];
int grundy(int x) {
  int& res = cache[x];
  if (~res) return res;
  int i, j, k;
  set<int> st;
  pile[x] = N;
  for (i = 0; i < divide[x].size(); i++) {
    int state = 0;
    for (j = divide[x][i].first; j <= divide[x][i].second; j++) {
      state ^= grundy(j);
    }
    st.insert(state);
    if (state == 0) {
      pile[x] = min(pile[x], divide[x][i].second - divide[x][i].first + 1);
    }
  }
  res = 0;
  while (st.count(res)) res++;
  return res;
}
int main() {
  int i, j, tcc, tc = 1 << 28;
  for (i = 1; i < N; i++) {
    for (j = i + 1; j < N; j++) {
      long long sum = ((long long)j * (j + 1) - (long long)i * (i - 1)) / 2;
      if (sum >= N) break;
      divide[sum].push_back(make_pair(i, j));
    }
  }
  memset(cache, ~0, sizeof(cache));
  for (tcc = 0; tcc < tc; tcc++) {
    int x = getint();
    if (grundy(x) == 0) {
      puts("-1");
    } else {
      printf("%d\n", pile[x]);
    }
  }
  return 0;
}
