#include <bits/stdc++.h>
using namespace std;
int dp[100005], dpac[100005], N;
int sz, here[100005];
int mex(int sz) {
  sort(here, here + sz);
  sz = unique(here, here + sz) - here;
  int lo = -1, hi = sz, mid;
  while (hi - lo > 1) {
    mid = (lo + hi) / 2;
    if (mid != here[mid])
      hi = mid;
    else
      lo = mid;
  }
  return hi;
}
int main() {
  cin >> N;
  int ans;
  for (int n = 3; n <= N; n++) {
    ans = 1 << 30;
    sz = 0;
    for (int j = 2; j * j <= 2 * n; j++)
      if (2 * n % j == 0) {
        int k = j, a;
        if ((2 * n - k * k + k) % (2 * k) == 0) {
          a = (2 * n - k * k + k) / (2 * k);
          if (a > 0) {
            here[sz++] = dpac[a + k - 1] ^ dpac[a - 1];
            if (here[sz - 1] == 0) ans = min(ans, k);
          }
        }
        k = (2 * n) / j;
        if ((2 * n - k * k + k) % (2 * k) == 0) {
          a = (2 * n - k * k + k) / (2 * k);
          if (a > 0) {
            here[sz++] = dpac[a + k - 1] ^ dpac[a - 1];
            if (here[sz - 1] == 0) ans = min(ans, k);
          }
        }
      }
    dp[n] = mex(sz);
    dpac[n] = dpac[n - 1] ^ dp[n];
  }
  if (dp[N]) {
    cout << ans << endl;
  } else {
    cout << -1 << endl;
  }
}
