#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 2, maxlim = 450;
int grundy[maxn];
int parts[maxn];
int prexor[maxn];
void process() {
  for (int i = 1; i < maxn; i++) {
    vector<int> seq, compress;
    for (int j = 2; j <= maxlim; j++) {
      int val = (2 * i) / j + 1 - j;
      if ((2 * i) % j == 0 && val >= 2 && val % 2 == 0) {
        int st = val / 2;
        st = prexor[st + j - 1] ^ prexor[st - 1];
        seq.push_back(st);
        if (st == 0 && parts[i] == 0) parts[i] = j;
      }
    }
    sort(seq.begin(), seq.end());
    if (!seq.empty()) {
      compress.push_back(seq[0]);
      for (int i = 1; i < seq.size(); i++) {
        if (seq[i] != compress.back()) compress.push_back(seq[i]);
      }
    }
    int pos = 0;
    for (pos = 0; pos < compress.size(); pos++) {
      if (compress[pos] != pos) break;
    }
    grundy[i] = pos;
    prexor[i] = pos ^ prexor[i - 1];
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  process();
  int n;
  cin >> n;
  if (grundy[n] == 0)
    cout << -1;
  else
    cout << parts[n];
  return 0;
}
