#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-10;
const double PI = acos(-1.0);
template <class T>
T gcd(T a, T b) {
  for (T c; b; c = a, a = b, b = c % b)
    ;
  return a;
}
template <class T>
void out(const vector<T> &a) {
  for (int i = 0; i < ((int)(a).size()); ++i) cout << a[i] << " ";
  cout << endl;
}
int countbit(int n) { return n == 0 ? 0 : 1 + countbit(n & (n - 1)); }
const int d8[8][2] = {{1, 0}, {-1, 0},  {0, 1},  {0, -1},
                      {1, 1}, {-1, -1}, {1, -1}, {-1, 1}};
const int d4[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
inline int dcmp(double x) { return (x > EPS) - (x < -EPS); }
inline double cross(const complex<double> &a, const complex<double> &b) {
  return (conj(a) * b).imag();
}
inline double dot(const complex<double> &a, const complex<double> &b) {
  return (conj(a) * b).real();
}
const int N = 100000 + 10;
int ans[N];
int SG[N];
int seen[N];
int main() {
  int n;
  cin >> n;
  fill(seen, seen + N, -1);
  for (int i = 1; i <= n; ++i) {
    ans[i] = INT_MAX;
    for (int j = 2; j * (j + 1) / 2 <= i; ++j)
      if ((i - j * (j + 1) / 2) % j == 0) {
        int k = (i - j * (j + 1) / 2) / j;
        int sum_xor = 0;
        for (int u = 1; u <= j; ++u) sum_xor ^= SG[k + u];
        seen[sum_xor] = i;
        if (sum_xor == 0) ans[i] = min(ans[i], j);
      }
    int j;
    for (j = 0; seen[j] == i; ++j)
      ;
    SG[i] = j;
  }
  if (ans[n] == INT_MAX)
    cout << -1 << endl;
  else
    cout << ans[n] << endl;
  return 0;
}
