#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:0x04000000")
using namespace std;
struct ak {
  int a, k;
  ak(int aa = 0, int kk = 0) : a(aa), k(kk) {}
};
const int MAXN = 100005;
bool us[MAXN];
int val[MAXN], dyn[MAXN];
vector<ak> pos[MAXN];
long long f(int a, int k) { return (long long)k * (a + a - k + 1) / 2; }
int mex(int n, const int maxn, bool *us, int *val) {
  memset(us, 0, maxn * sizeof(bool));
  for (int i = 0; i < (int)(n); i++) {
    us[val[i]] = true;
  }
  int res;
  for (res = 0; us[res]; res++) {
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cout.setf(cout.fixed);
  cout.precision(20);
  int n;
  cin >> n;
  for (int k = (int)(2); k < (int)(n + 1); k++) {
    for (int a = k; f(a, k) <= n; a++) {
      pos[f(a, k)].push_back(ak(a, k));
    }
  }
  for (int i = (int)(1); i < (int)(n + 1); i++) {
    int sz = 0;
    for (int j = 0; j < (int)((int)(pos[i]).size()); j++) {
      int a = pos[i][j].a, k = pos[i][j].k;
      val[sz++] = dyn[a] ^ dyn[a - k];
    }
    dyn[i] = dyn[i - 1] ^ mex(sz, MAXN, us, val);
  }
  if (dyn[n] ^ dyn[n - 1]) {
    int resk = MAXN;
    for (int i = 0; i < (int)((int)(pos[n]).size()); i++) {
      int a = pos[n][i].a, k = pos[n][i].k;
      if ((dyn[a] ^ dyn[a - k]) == 0) {
        resk = min(resk, k);
        break;
      }
    }
    cout << resk << endl;
  } else {
    cout << -1 << endl;
  }
}
