#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100200;
int f[MAXN], v[MAXN];
int calc(int n) {
  int mk = -1;
  for (int k = 2; k * k < (n << 1); k++)
    if ((n << 1) % k == 0) {
      int a1 = (n << 1) / k - (k - 1);
      if (a1 <= 0 || (a1 & 1) == 1) continue;
      a1 = a1 >> 1;
      int ev = 0;
      for (int j = 0; j < k; j++) ev ^= f[a1 + j];
      v[ev] = n;
      if (ev == 0 && mk == -1) mk = k;
    }
  for (f[n] = 0; v[f[n]] == n; f[n]++)
    ;
  return mk;
}
int main() {
  int N;
  cin >> N;
  memset(v, 0, sizeof(v));
  for (int i = 1; i < N; i++) calc(i);
  int z = calc(N);
  if (f[N] == 0)
    cout << -1 << endl;
  else
    cout << z << endl;
  return 0;
}
