#include <bits/stdc++.h>
using namespace std;
template <class T>
T abs(T x) {
  return x > 0 ? x : -x;
}
int n;
int m;
int was[200];
int use[100001];
int g[100001];
int main() {
  scanf("%d", &n);
  g[0] = 0;
  for (int i = 1; i <= n; i++) {
    use[i] = -1;
    for (int k = 500; k > 1; k--)
      if ((2 * i) % k == 0 && ((2 * i) / k - k + 1) % 2 == 0) {
        int j = ((2 * i) / k - k + 1) / 2;
        if (j <= 0) continue;
        int tmp = 0;
        for (int l = 0; l < k; l++) tmp ^= g[j + l];
        if (tmp == 0) use[i] = k;
        was[tmp] = i;
      }
    int j = 0;
    while (was[j] == i) j++;
    g[i] = j;
  }
  printf("%d\n", use[n]);
  return 0;
}
