#include <bits/stdc++.h>
using namespace std;
long long grundyVal[100010];
long long n, vAcum[100010];
bitset<100010> noMex;
int grundy(int n, bool showAns) {
  long long ans = -1;
  if (n <= 2) {
    if (showAns) cout << "-1\n";
    return 0;
  }
  if (grundyVal[n] != -1) {
    assert(!showAns);
    return grundyVal[n];
  }
  vector<int> v;
  set<int> noMex;
  for (long long k = (1); k < (n); k++) {
    int l = k + 1, r = n, m;
    while (l < r) {
      m = (l + r) / 2;
      if (vAcum[m] - vAcum[k - 1] < n)
        l = m + 1;
      else
        r = m;
    }
    long long acum = vAcum[r] - vAcum[k - 1];
    long long xorAcum = 0;
    if (acum != n) continue;
    for (long long j = (k); j < (r + 1); j++) xorAcum ^= grundy(j, false);
    noMex.insert(xorAcum);
    if (xorAcum == 0) {
      if (ans == -1) ans = r - k + 1;
      ans = min(ans, r - k + 1);
    }
    if (ans == 2 && showAns) break;
  }
  for (long long j = (0); j < (100010); j++)
    if (!noMex.count(j)) {
      grundyVal[n] = j;
      break;
    }
  if (showAns == true) cout << ans << '\n';
  return grundyVal[n];
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  for (long long i = (1); i < (100010); i++) {
    vAcum[i] = vAcum[i - 1] + i;
  }
  memset(grundyVal, -1, sizeof(grundyVal));
  while (cin >> n) grundy(n, true);
  return 0;
}
