#include <bits/stdc++.h>
using namespace std;
const double eps = 0.0000000000001;
int dp[100010] = {0};
int los[100010] = {0};
int gr(int x) {
  int k = 2, i;
  if (dp[x] != -1) return dp[x];
  int hs[100] = {0};
  for (; k * (k - 1) / 2 <= x; k++) {
    int lo = 0;
    if ((x - k * (k - 1) / 2) % k == 0 && (x - k * (k - 1) / 2) / k > 0) {
      int a1 = (x - k * (k - 1) / 2) / k;
      for (i = 0; i < k; i++) {
        lo ^= gr(i + a1);
      }
      if (lo == 0 && los[x] == -1) {
        los[x] = k;
      }
      hs[lo]++;
    }
  }
  for (i = 0; i < 100; i++)
    if (!hs[i]) break;
  return dp[x] = i;
}
int main() {
  int i, n;
  for (i = 0; i < 100001; i++) {
    dp[i] = -1;
    los[i] = -1;
  }
  scanf("%d", &n);
  int ans = gr(n);
  if (ans) {
    assert(los[n] != -1);
    printf("%d\n", los[n]);
  } else
    printf("-1\n");
  return 0;
}
