#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
int n, sg[MAXN] = {}, mx[MAXN] = {}, res[MAXN];
void calc(int x) {
  res[x] = -1;
  for (int i = 2; i * (i + 1) <= 2 * x; i++) {
    int a = (2 * x / i + 1 - i) / 2;
    if ((2 * a + i - 1) * i != 2 * x) continue;
    int xs = 0;
    for (int j = 0; j < i; j++) xs ^= sg[a + j];
    mx[xs] = x;
    if (xs == 0 && res[x] < 0) res[x] = i;
  }
  while (mx[sg[x]] == x) sg[x]++;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) calc(i);
  cout << res[n] << '\n';
}
