#include <bits/stdc++.h>
using namespace std;
long long mpow(long long a, long long n) {
  long long ret = 1;
  long long b = a;
  while (n) {
    if (n & 1) ret = (ret * b) % 1000000007;
    b = (b * b) % 1000000007;
    n >>= 1;
  }
  return (long long)ret;
}
int main() {
  int n, nn, pre[1000009] = {}, g[1000009] = {}, ans = INT_MAX;
  cin >> nn;
  for (int i = 1; i <= nn; i++) {
    n = i;
    int cur = 0;
    set<int> myset;
    for (int p = 1; (p * (p + 1)) / 2 <= n; p++) {
      if ((n - (p * (p + 1)) / 2) % (p + 1)) continue;
      int k = (n - (p * (p + 1)) / 2) / (p + 1);
      if (k == 0) continue;
      if (i == nn && (pre[k + p] ^ pre[k - 1]) == 0) ans = min(ans, p + 1);
      myset.insert(pre[k + p] ^ pre[k - 1]);
    }
    while (myset.find(cur) != myset.end()) cur++;
    g[i] = cur;
    pre[i] = pre[i - 1] ^ g[i];
  }
  if (g[nn] != 0)
    cout << ans << endl;
  else
    cout << -1 << endl;
  return 0;
}
