#include <bits/stdc++.h>
using namespace std;
int grundy[100005], sum[100005];
set<int> s;
int ret = -1, n;
void add(int m, int k) {
  int alpha = m / k, beta = k - 1;
  if ((alpha - beta) % 2) return;
  int a = (alpha - beta) / 2;
  if (a <= 0) return;
  int b = a + k - 1;
  s.insert(sum[a - 1] ^ sum[b]);
  if (m == 2 * n && sum[a - 1] == sum[b])
    if (ret < 0 || ret > k) ret = k;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    s.clear();
    int m = 2 * i;
    for (int k = 2; k * k <= m; k++)
      if (m % k == 0) {
        add(m, k);
        add(m, m / k);
      }
    for (int k = 0;; k++)
      if (s.find(k) == s.end()) {
        grundy[i] = k;
        sum[i] = sum[i - 1] ^ grundy[i];
        break;
      }
  }
  printf("%d\n", ret);
}
