#include <bits/stdc++.h>
using namespace std;
const int N = 100000 + 10;
int n, sg[N], sum[N], a[N], tot;
int main() {
  scanf("%d", &n);
  for (int i = 2; i <= n; i++) {
    tot = 0;
    for (int k = 2;; k++) {
      if (k + k * k > 2 * i) break;
      if ((2 * i - k * k + k) % (2 * k)) continue;
      int x = (2 * i - k * k + k) / (2 * k);
      a[++tot] = sum[x + k - 1] ^ sum[x - 1];
    }
    if (tot == 0)
      sg[i] = 0;
    else {
      sort(a + 1, a + tot + 1);
      a[tot + 1] = -1;
      if (a[1] != 0)
        sg[i] = 0;
      else {
        for (int j = 2; j <= tot + 1; j++)
          if (a[j] != a[j - 1] && a[j] != a[j - 1] + 1) {
            sg[i] = a[j - 1] + 1;
            break;
          }
      }
    }
    sum[i] = sum[i - 1] ^ sg[i];
  }
  if (!sg[n]) {
    printf("-1\n");
    return 0;
  }
  for (int k = 2;; k++) {
    if (k + k * k > 2 * n) break;
    if ((2 * n - k * k + k) % (2 * k)) continue;
    int x = (2 * n - k * k + k) / (2 * k);
    if ((sum[x + k - 1] ^ sum[x - 1]) == 0) {
      printf("%d\n", k);
      return 0;
    }
  }
}
