#include <bits/stdc++.h>
using namespace std;
int n;
int dp[100002];
int f(int x) {
  if (dp[x] != -1) return dp[x];
  bool nim[100] = {};
  for (int i = 2; i * (i - 1) < 2 * x; i++) {
    if ((2 * x - i * (i - 1)) % (2 * i) == 0) {
      int tmp = 0, xx = (2 * x - i * (i - 1)) / (2 * i);
      for (int j = 0; j < i; j++) tmp ^= f(xx + j);
      nim[tmp] = 1;
      if (tmp == 0 && x == n) {
        printf("%d\n", i);
        return 1;
      }
    }
  }
  int ret = 0;
  while (nim[ret]) ret++;
  return dp[x] = ret;
}
int main() {
  scanf("%d", &n);
  memset(dp, -1, sizeof dp);
  if (f(n))
    ;
  else
    printf("-1\n");
  return 0;
}
