#include <bits/stdc++.h>
int dr[] = {2, 2, -2, -2, 1, -1, 1, -1};
int dc[] = {1, -1, 1, -1, 2, 2, -2, -2};
int dr1[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dc1[] = {-1, 1, -1, 0, 1, -1, 0, 1};
int dr2[] = {-1, -1, -1};
int dc2[] = {-1, 1, 0};
using namespace std;
long long int dp[1000002], b[1000002];
vector<pair<long long int, long long int> > adj[1000002];
long long int cal(long long int x) {
  if (x <= 2) return 0;
  set<long long int> s;
  set<long long int>::iterator it;
  for (long long int i = 0; i < adj[x].size(); i++) {
    long long int p = adj[x][i].first;
    long long int q = adj[x][i].second;
    long long int r = b[q] ^ b[p - 1];
    s.insert(r);
  }
  long long int cn = 0;
  for (it = s.begin(); it != s.end(); it++) {
    long long int k = *it;
    if (k == cn)
      cn++;
    else
      break;
  }
  return cn;
}
void pre() {
  long long int i, j;
  for (i = 3; i <= 100000; i++) {
    long long int s = 0;
    for (j = 2; j <= i; j++) {
      s += (j - 1);
      if (s > i) break;
      long long int k = i - s;
      if (k % j != 0) continue;
      long long int r = k / j;
      if (r == 0) continue;
      adj[i].push_back(make_pair(r, r + j - 1));
    }
  }
}
long long int getk(long long int x) {
  long long int i, j;
  long long int min1 = 100000000;
  for (i = 0; i < adj[x].size(); i++) {
    long long int p = adj[x][i].first;
    long long int q = adj[x][i].second;
    long long int r = b[q] ^ b[p - 1];
    if (r == 0) min1 = min(min1, q - p + 1);
  }
  return min1;
}
int main() {
  long long int n, i, j;
  pre();
  for (i = 1; i <= 100000; i++) {
    dp[i] = cal(i);
    b[i] = b[i - 1] ^ dp[i];
  }
  while (cin >> n) {
    if (dp[n] == 0) {
      cout << "-1" << endl;
      continue;
    }
    long long int ans = getk(n);
    cout << ans << endl;
  }
  return 0;
}
