#include <bits/stdc++.h>
using namespace std;
struct _ {
  _() { ios_base::sync_with_stdio(0); }
} _;
template <class A, class B>
ostream &operator<<(ostream &o, pair<A, B> t) {
  o << "(" << t.first << ", " << t.second << ")";
  return o;
}
template <class T>
void PV(T a, T b) {
  while (a != b) cout << *a++, cout << (a != b ? " " : "\n");
}
template <class T>
inline bool chmin(T &a, T b) {
  return a > b ? a = b, 1 : 0;
}
template <class T>
inline bool chmax(T &a, T b) {
  return a < b ? a = b, 1 : 0;
}
template <class T>
string tostring(T first, int len = 0) {
  stringstream ss;
  ss << first;
  string r = ss.str();
  if (r.length() < len) r = string(len - r.length(), '0') + r;
  return r;
}
template <class T>
void convert(string first, T &r) {
  stringstream ss(first);
  ss >> r;
}
const int inf = 0x3f3f3f3f;
const int mod = int(1e9) + 7;
const int N = 111111;
int n;
int SG[N];
int xr[N];
long long s[N];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) s[i] = s[i - 1] + i;
  int res = inf;
  SG[1] = 0;
  SG[2] = 0;
  for (int i = 3; i <= n; i++) {
    vector<int> mex;
    int t = 2 * i;
    for (int j = 1; j * j <= t; j++) {
      if (t % j != 0) continue;
      int t1 = j - 1;
      int t2 = t / j;
      if ((t1 + t2) % 2) continue;
      assert(t1 <= t2);
      int first = (t2 - t1) / 2;
      int second = (t2 + t1) / 2;
      if (first == second) continue;
      assert(s[second] - s[first - 1] == i);
      int xorsum = xr[second] ^ xr[first - 1];
      mex.push_back(xorsum);
      if (i == n && xorsum == 0) chmin(res, second - first + 1);
    }
    sort((mex).begin(), (mex).end()),
        mex.resize(unique((mex).begin(), (mex).end()) - mex.begin());
    for (int j = 0; j < mex.size(); j++)
      if (SG[i] == mex[j]) SG[i]++;
    xr[i] = xr[i - 1] ^ SG[i];
  }
  if (SG[n] == 0)
    cout << -1 << endl;
  else
    cout << res << endl;
  return 0;
}
