#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int dp[maxn], sum[maxn], ans[maxn], f[maxn];
int n, INF;
int main() {
  scanf("%d", &n);
  memset(ans, 0xf, sizeof(ans));
  int INF = ans[0];
  for (int i = 1; i <= n; i++) {
    int tmp = 2 * i;
    for (int j = 2; j * j <= tmp; j++) {
      if (tmp % j == 0) {
        int k = tmp / j + 1 - j;
        if (k % 2) continue;
        k >>= 1;
        if (k < 1) continue;
        int ret = sum[k - 1] ^ sum[k + j - 1];
        f[ret] = i;
        if (!ret) ans[i] = min(ans[i], j);
      }
    }
    for (int j = 0;; j++) {
      if (f[j] != i) {
        dp[i] = j;
        break;
      }
    }
    sum[i] = sum[i - 1] ^ dp[i];
  }
  printf("%d\n", (ans[n] == INF) ? -1 : ans[n]);
  return 0;
}
