#include <bits/stdc++.h>
using namespace std;
const int N = int(1e5) + 1;
int dp[N];
bool seen[N];
int grundy(int n) {
  if (seen[n]) {
    return dp[n];
  }
  seen[n] = true;
  set<int> minimax;
  for (int t = 2; t * t <= (2 * n); t++) {
    int x = n - (t * (t - 1)) / 2;
    if (x <= 0 || x % t) {
      continue;
    }
    x /= t;
    int sum = 0;
    for (int i = 0; i < t; i++) {
      sum ^= grundy(x + i);
    }
    minimax.insert(sum);
  }
  int ret = 0;
  while (minimax.count(ret)) {
    ret++;
  }
  dp[n] = ret;
  return ret;
}
int main(void) {
  int n;
  scanf("%i", &n);
  int ret = grundy(n);
  if (ret) {
    for (int t = 2; t * t <= 2 * n; t++) {
      int x = n - (t * (t - 1)) / 2;
      if (x <= 0 || x % t) {
        continue;
      }
      x /= t;
      int sum = 0;
      for (int i = 0; i < t; i++) {
        sum ^= grundy(x + i);
      }
      if (!sum) {
        printf("%i\n", t);
        break;
      }
    }
  } else {
    printf("-1\n");
  }
  return 0;
}
