#include <bits/stdc++.h>
using namespace std;
static const double EPS = 1e-8;
int memo[100010];
int rec(int n) {
  if (memo[n] >= 0) return memo[n];
  set<int> piles;
  int hi = (n + 1) / 2, lo = hi - 1;
  while (1) {
    while ((hi + lo) * (hi - lo + 1) / 2 < n && lo > 0) lo--;
    if (lo == 0) break;
    while ((hi + lo) * (hi - lo + 1) / 2 > n && hi > lo) hi--;
    if ((hi + lo) * (hi - lo + 1) / 2 == n) {
      int pile = 0;
      for (int j = lo; j <= hi; j++) pile ^= rec(j);
      piles.insert(pile);
      hi--;
    }
  }
  memo[n] = 0;
  while (piles.count(memo[n])) memo[n]++;
  return memo[n];
}
int solve(int n) {
  int hi = (n + 1) / 2, lo = hi - 1;
  while (1) {
    while ((hi + lo) * (hi - lo + 1) / 2 < n && lo > 0) lo--;
    if (lo == 0) break;
    while ((hi + lo) * (hi - lo + 1) / 2 > n && hi > lo) hi--;
    if ((hi + lo) * (hi - lo + 1) / 2 == n) {
      int pile = 0;
      for (int j = lo; j <= hi; j++) pile ^= rec(j);
      if (pile == 0) return hi - lo + 1;
      hi--;
    }
  }
  return -1;
}
int main() {
  istream &fin = cin;
  ostream &fout = cout;
  FILE *fpin = stdin;
  FILE *fpout = stdout;
  memset(memo, -1, sizeof(memo));
  int n;
  fin >> n;
  fout << solve(n) << endl;
}
