#include <bits/stdc++.h>
using namespace std;
int memo[100005], pd[100005];
int grundy(int n) {
  if (n <= 2) return 0;
  int &ret = memo[n];
  if (ret != -1) return ret;
  set<int> MEX;
  pd[n] = (1 << 30);
  for (int i = 2; i * i <= 2 * n; i++) {
    int xi = (2 * n) / i - 1 + i;
    if ((2 * n) % i != 0) continue;
    if (xi % 2 != 0) continue;
    xi /= 2;
    int sum1 = 0;
    for (int j = 0; j < i; j++) sum1 ^= grundy(xi - j);
    MEX.insert(sum1);
    if (sum1 == 0 && pd[n] > i) pd[n] = i;
  }
  int nim = 0;
  while (MEX.count(nim)) nim++;
  return ret = nim;
}
int main() {
  int n;
  while (cin >> n) {
    memset(memo, -1, sizeof memo);
    int ans = grundy(n);
    if (ans == 0)
      puts("-1");
    else
      printf("%d\n", pd[n]);
  }
}
