#include <bits/stdc++.h>
using namespace std;
const long double pi = 3.14159265359;
template <typename T>
T abs(T x) {
  return x > 0 ? x : -x;
}
template <typename T>
T sqr(T x) {
  return x * x;
}
const int maxn = 100005;
int a[maxn];
int s[maxn];
vector<pair<int, int>> b[maxn];
int used[maxn];
int currUsed = 1;
int xr(int l, int r) { return s[r] ^ (l ? s[l - 1] : 0); }
int main() {
  for (long long l = 1; l < maxn; l++) {
    for (long long r = l + 1;; r++) {
      long long cnt = r * (r + 1) / 2 - (l - 1) * l / 2;
      if (cnt >= maxn) {
        break;
      }
      b[cnt].push_back(make_pair(l, r));
    }
  }
  for (int i = 1; i < maxn; i++) {
    currUsed++;
    for (auto p : b[i]) {
      used[xr(p.first, p.second)] = currUsed;
    }
    while (used[a[i]] == currUsed) {
      a[i]++;
    }
    s[i] = s[i - 1] ^ a[i];
  }
  int n;
  cin >> n;
  if (a[n]) {
    int ans = 1e9;
    for (auto p : b[n]) {
      if (!xr(p.first, p.second)) {
        ans = min(ans, p.second - p.first + 1);
      }
    }
    cout << ans << endl;
  } else {
    cout << -1 << endl;
  }
  return 0;
}
