#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
const int DIM = 110 * 1000;
int dn[DIM];
int n;
int nim(int n) {
  if (dn[n] != -1) return dn[n];
  int res = 0;
  vector<int> v;
  for (int k = (2); k < (n); k++) {
    int x = (2 * n + (long long)k * (k - 1)) / 2 / k;
    if ((k * x - (k * (k - 1)) / 2) == n && x > k - 1) {
      int cand = 0;
      for (int i = (0); i < (k); i++) {
        cand ^= nim(x - i);
      }
      v.push_back(cand);
    }
  }
  sort(v.begin(), v.end());
  v.resize(unique(v.begin(), v.end()) - v.begin());
  int p = 0;
  while ((int)(v.size()) > p && v[p] == p) p++;
  res = p;
  return dn[n] = res;
}
int main() {
  memset(dn, -1, sizeof(dn));
  scanf("%d", &n);
  int ans = nim(n);
  if (ans == 0)
    printf("-1\n");
  else {
    for (int k = (2); k < (n); k++) {
      int x = (2 * n + (long long)k * (k - 1)) / 2 / k;
      if ((k * x - (k * (k - 1)) / 2) == n && x > k - 1) {
        int cand = 0;
        for (int i = (0); i < (k); i++) {
          cand ^= nim(x - i);
        }
        if (cand == 0) {
          printf("%d\n", k);
          return 0;
        }
      }
    }
  }
  return 0;
}
