#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
template <typename T>
using minpq = priority_queue<T, vector<T>, greater<T>>;
template <typename T>
using maxpq = priority_queue<T>;
inline long long CC(long long n, long long y) {
  return (((n) + (y - 1) - 1) / (y - 1)) - (((n) + (y)-1) / (y));
}
inline long long FF(long long n, long long y) { return n / y - n / (y + 1); }
inline int add(int a, int b, int p = 1000000007) {
  int c = a + b;
  if (c >= p) c -= p;
  return c;
}
inline int sub(int a, int b, int p = 1000000007) {
  int c = a - b;
  if (c < 0) c += p;
  return c;
}
inline int mul(int a, int b, int p = 1000000007) { return (a * 1ll * b) % p; }
inline long long nC2(long long n) { return n * (n - 1) / 2; }
long long n, pre[100005], g[100005], mn[100005], cnt[100005];
long long query(long long l, long long r) {
  return pre[r] ^ (l ? pre[l - 1] : 0);
}
long long G(long long i) {
  long long j, k = 2;
  bool ok = 0;
  set<long long> s;
  while (i - nC2(k) > 0) {
    long long kk = i - nC2(k);
    if (kk % k == 0) {
      j = kk / k;
      long long x = query(j, j + k - 1);
      s.insert(x);
      if (!ok && !x) {
        mn[i] = k;
        ok = 1;
      }
    }
    k++;
  }
  cnt[i] = k;
  j = 0;
  while (1) {
    if (!s.count(j++)) return --j;
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL);
  clock_t clk = clock();
  cerr << "I will return...\n";
  cin >> n;
  g[0] = g[1] = 0;
  for (long long i = (2); i < (n + 1); i++) {
    g[i] = G(i);
    pre[i] = pre[i - 1] ^ g[i];
  }
  if (!g[n])
    cout << -1 << '\n';
  else
    cout << mn[n] << '\n';
  cerr << "...don't you ever hang your head.\n";
  cerr << "Time (in ms): " << double(clock() - clk) * 1000.0 / CLOCKS_PER_SEC
       << '\n';
}
