#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > di[100005];
int pref[100005];
int u[100005];
int g[100005];
int ans;
int n;
void pre() {
  for (int l = 1; l <= 100000; ++l) {
    int sum = l + l + 1;
    for (int r = l + 1; sum <= 100000; sum += ++r) {
      di[sum].push_back(make_pair(l, r));
    }
  }
}
void solve() {
  scanf("%d", &n);
  ans = n;
  for (int i = 1, cur; i <= n; ++i) {
    for (auto it : di[i]) {
      int v = pref[it.second] ^ pref[it.first - 1];
      if (i == n && v == 0) {
        ans = min(ans, it.second - it.first + 1);
      }
      u[v] = i;
    }
    for (cur = 0; u[cur] == i; ++cur)
      ;
    g[i] = cur;
    pref[i] = pref[i - 1] ^ g[i];
  }
  if (ans == n) {
    ans = -1;
  }
  printf("%d\n", ans);
}
int main() {
  int tt = 1;
  pre();
  while (tt--) {
    solve();
  }
  return 0;
}
