#include <bits/stdc++.h>
using namespace std;
string itoa(long long a) {
  string ret;
  for (long long i = a; i > 0; i = i / 10) ret += ((i % 10) + 48);
  reverse(ret.begin(), ret.end());
  return ret;
}
int toi(string s) {
  int r = 0;
  istringstream sin(s);
  sin >> r;
  return r;
}
long long toi64(string s) {
  long long r = 0;
  istringstream sin(s);
  sin >> r;
  return r;
}
double tod(string s) {
  double r = 0;
  istringstream sin(s);
  sin >> r;
  return r;
}
vector<string> token(string a, string b) {
  const char *q = a.c_str();
  while (count(b.begin(), b.end(), *q)) q++;
  vector<string> oot;
  while (*q) {
    const char *e = q;
    while (*e && !count(b.begin(), b.end(), *e)) e++;
    oot.push_back(string(q, e));
    q = e;
    while (count(b.begin(), b.end(), *q)) q++;
  }
  return oot;
}
template <class T>
inline T gcd(T a, T b) {
  if (a < 0) return gcd(-a, b);
  if (b < 0) return gcd(a, -b);
  return (b == 0) ? a : gcd(b, a % b);
}
template <class T>
inline T lcm(T a, T b) {
  if (a < 0) return lcm(-a, b);
  if (b < 0) return lcm(a, -b);
  return a * (b / gcd(a, b));
}
template <class T>
inline T sqr(T x) {
  return x * x;
}
template <class T>
inline T power(T x, T p) {
  if (!p) return 1;
  return x * power(x, p - 1);
}
const int mx = 100000 + 10;
int dp[mx];
int grundy(int n) {
  int &ret = dp[n];
  if (ret != -1) return ret;
  set<int> ase;
  for (int k = 2;; k++) {
    int sum = k * (k + 1) / 2;
    if (sum > n) break;
    if ((n - sum) % k) continue;
    int val = 0;
    for (int i = 1, a = ((n - sum) / k) + 1; i <= k; i++, a++) val ^= grundy(a);
    ase.insert(val);
  }
  for (ret = 0;; ret++)
    if (ase.find(ret) == ase.end()) return ret;
}
int solve(int n) {
  memset((dp), (-1), sizeof(dp));
  ;
  for (int k = 2;; k++) {
    int sum = k * (k + 1) / 2;
    if (sum > n) break;
    if ((n - sum) % k) continue;
    int val = 0;
    for (int i = 1, a = ((n - sum) / k) + 1; i <= k; i++, a++) val ^= grundy(a);
    if (!val) return k;
  }
  return -1;
}
int main() {
  int n;
  while (cin >> n) cout << solve(n) << endl;
  return 0;
}
