#include <bits/stdc++.h>
using namespace std;
const long long sz = 1e5 + 10;
vector<pair<int, int> > g[sz];
long long grundy[sz], pre[sz];
long long findMex(set<int> &lst) {
  long long mex = 0;
  auto it = lst.begin();
  while (it != lst.end() && *it == mex) ++it, ++mex;
  return mex;
}
int main() {
  for (long long i = 1; i <= sz - 1; ++i) {
    long long sum = i;
    for (long long j = i + 1; j < sz; j++) {
      sum += j;
      if (sum >= sz) break;
      g[sum].push_back(make_pair(i, j));
    }
  }
  grundy[1] = grundy[2] = pre[1] = pre[2] = 0;
  for (long long i = 3; i < sz; i++) {
    set<int> lst;
    for (pair<int, int> &p : g[i]) {
      long long l = p.first, r = p.second;
      long long Xor = pre[r] ^ pre[l - 1];
      lst.insert(Xor);
    }
    grundy[i] = findMex(lst);
    pre[i] = grundy[i] ^ pre[i - 1];
  }
  long long n;
  scanf("%lld", &n);
  if (grundy[n] == 0) {
    cout << -1 << '\n';
    return 0;
  }
  long long k = (1LL << 61);
  for (pair<int, int> &p : g[n]) {
    long long l = p.first, r = p.second;
    long long Xor = pre[r] ^ pre[l - 1];
    if (Xor == 0) k = min(k, r - l + 1);
  }
  cout << k << '\n';
  return 0;
}
