#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;
const int MAXK = 450;
int grundy[MAXN];
int xsum[MAXN];
int main() {
  int n;
  scanf("%d", &n);
  if (n == 1) {
    puts("-1");
    return 0;
  }
  for (int i = 2; i <= n; i++) {
    bool tmp[MAXK] = {};
    for (long long k = 2; k * (k - 1) / 2 < i; k++) {
      long long ak = (i - k * (k - 1) / 2);
      if (ak % k != 0) continue;
      long long a = ak / k;
      int ret = 0;
      for (long long j = a; j < a + k; j++) {
        ret ^= grundy[j];
      }
      tmp[ret] = true;
    }
    int mex = 0;
    while (tmp[mex]) mex++;
    grundy[i] = mex;
  }
  if (!grundy[n]) {
    puts("-1");
    return 0;
  }
  for (int i = 1; i <= n; i++) xsum[i] = xsum[i - 1] ^ grundy[i];
  long long ans = -1;
  for (long long k = 2; k * (k - 1) / 2 < n; k++) {
    long long ak = (n - k * (k - 1) / 2);
    if (ak % k != 0) continue;
    long long a = ak / k;
    int ret = xsum[a + k - 1] ^ xsum[a - 1];
    if (!ret) {
      ans = k;
      break;
    }
  }
  printf("%lld", ans);
  return 0;
}
