#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int MAX_N = 1e5 + 10;
int grundy[MAX_N];
int solve(int n) {
  int& ret = grundy[n];
  if (~ret) return ret;
  set<int> s;
  for (int l = 1; l < n; ++l) {
    int x = n - (l * l + l) / 2;
    if (x <= 0) break;
    if (x % (1 + l) == 0) {
      x /= (1 + l);
      int xorr = 0;
      for (int i = x; i <= x + l; ++i) {
        xorr ^= solve(i);
      }
      s.insert(xorr);
    }
  }
  ret = 0;
  while (s.count(ret)) ++ret;
  return ret;
}
int acc[100010];
int main() {
  acc[0] = 0;
  for (int i = 1; i < 10000; ++i) {
    acc[i] = acc[i - 1] + i;
  }
  int n;
  scanf("%d", &n);
  memset(grundy, -1, sizeof grundy);
  int gn = solve(n);
  if (gn != 0) {
    int ans = -1;
    for (int l = 1; l < n; ++l) {
      int x = n - (l * l + l) / 2;
      if (x <= 0) break;
      if (x % (1 + l) == 0) {
        x /= (1 + l);
        int xorr = 0;
        for (int i = x; i <= x + l; ++i) {
          xorr ^= grundy[i];
        }
        if (xorr == 0) {
          ans = l + 1;
          break;
        }
      }
    }
    printf("%d\n", ans);
  } else
    printf("%d\n", -1);
  return 0;
}
