#include <bits/stdc++.h>
using namespace std;
inline long long getIndex(long long x) {
  long long l = 1, r = x, mid, ans = 1;
  while (l <= r) {
    mid = l + (r - l) / 2;
    if ((mid * (mid + 1)) / 2 <= x) {
      ans = mid;
      l = mid + 1;
    } else {
      r = mid - 1;
    }
  }
  return ans;
}
long long game[100100];
bool used[100100];
inline void Solve() {
  long long n, i, a, l, idx, j, mex, no;
  cin >> n;
  for (i = 0; i <= 100000; i++) {
    used[i] = false;
  }
  long double val;
  game[0] = 0;
  vector<long long> states;
  for (i = 1; i <= n; i++) {
    states.clear();
    idx = getIndex(i);
    for (j = idx; j >= 2; j--) {
      val = ((2.0 * i) / j - (j - 1.0)) / 2.0;
      if ((long long)val == val) {
        a = (long long)val;
        l = a + (j - 1);
        states.push_back(game[l] ^ game[a - 1]);
        if ((game[l] ^ game[a - 1]) == 0) {
          no = j;
        }
        used[(game[l] ^ game[a - 1])] = true;
      }
    }
    for (j = 0; j <= 100100; j++) {
      if (!used[j]) break;
    }
    game[i] = game[i - 1] ^ j;
    for (j = 0; j < states.size(); j++) {
      used[states[j]] = false;
    }
  }
  if ((game[n] ^ game[n - 1]) == 0) {
    cout << -1 << endl;
  } else {
    cout << no << endl;
  }
  return;
}
int main() {
  int t = 1;
  while (t--) {
    Solve();
  }
  return 0;
}
