#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
int n;
int a[111000];
int b[111000];
int iter;
int q[111000];
int get(int x, bool st = false) {
  ++iter;
  for (int _b = (x), i = (2); i <= _b; i++) {
    int grow = i * (i + 1) / 2;
    if (grow > x) break;
    if ((x - grow) % i == 0) {
      int s = 0;
      int add = (x - grow) / i + 1;
      for (int j = 0, _n = (i); j < _n; j++) s ^= a[add + j];
      q[s] = iter;
      if (st) b[i] = s;
    }
  }
  int res = 0;
  while (q[res] == iter) ++res;
  return res;
}
int main() {
  memset(q, -1, sizeof q);
  ;
  iter = 0;
  memset(a, 0, sizeof a);
  ;
  for (int x = 0, _n = (111000); x < _n; x++) {
    a[x] = get(x);
  }
  scanf("%d", &n);
  int res;
  if (a[n] == 0)
    res = -1;
  else {
    memset(b, -1, sizeof b);
    ;
    get(n, true);
    res = 0;
    while (b[res] != 0) res++;
  }
  printf("%d\n", res);
  return 0;
}
