#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void smn(T &a, const T &b) {
  if (b < a) a = b;
}
template <class T>
inline void smx(T &a, const T &b) {
  if (b > a) a = b;
}
template <class T>
inline T rev(const T &a) {
  T _ = a;
  reverse(_.begin(), _.end());
  return _;
}
const double eps = 1e-9;
const long double leps = 1e-14;
const int MN = 1000 * 100 + 1000;
int mark[MN];
int now;
int n;
int d[MN];
bool av(int a, int b) {
  b -= a * (a - 1) / 2;
  return (b % a == 0);
}
int first(int a, int b) {
  b -= a * (a - 1) / 2;
  return b / a;
}
int fnd(int a) {
  if (a <= 2) return 0;
  if (d[a] != -1) return d[a];
  now++;
  for (int i = 2; i * (i - 1) / 2 <= a; i++)
    if (av(i, a)) {
      int t = first(i, a), s = t, now = 0;
      while (s <= a) now ^= fnd(t), t++, s += t;
      mark[now] = ::now;
    }
  for (int i = 0;; i++)
    if (mark[i] != now) return d[a] = i;
}
int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin >> n;
  memset(d, -1, sizeof(d));
  for (int i = 0; i <= n; i++) fnd(i);
  if (fnd(n) == 0) {
    cout << -1 << '\n';
    return 0;
  }
  for (int i = 2; i * (i - 1) / 2 <= n; i++)
    if (av(i, n)) {
      int t = first(i, n), s = t, now = 0;
      while (s <= n) now ^= fnd(t), t++, s += t;
      if (now == 0) {
        cout << i << '\n';
        return 0;
      }
    }
  return 0;
}
