#include <bits/stdc++.h>
const int M = 100005;
int min(int a, int b) {
  if (a <= b) return a;
  return b;
}
int n, win[50005], sum[50005], val[M];
char f[M][35];
int main(int argc, char** argv) {
  int i, j, t, n2, ans, m, k;
  win[1] = win[2] = 0;
  win[3] = 1;
  while (1) {
    scanf("%d", &n);
    if (n <= 13) {
      if (n == 3 || (n == 9) || (n == 11))
        printf("2\n");
      else
        printf("-1\n");
      break;
    }
    int head = 1;
    int rear = 0;
    n2 = n / 2 + 1;
    for (i = 1; i <= n2; i++) {
      for (j = 0; j <= 34; j++) {
        if (f[i][j] == 0) {
          win[i] = j;
          break;
        }
      }
      t = head;
      for (j = head; j <= rear; j++) {
        sum[j] += i;
        if (sum[j] > n) {
          t = j + 1;
          continue;
        }
        val[j] ^= win[i];
        f[sum[j]][val[j]] = 1;
      }
      head = t;
      rear += 1;
      sum[rear] = i;
      val[rear] = win[i];
    }
    j = 1;
    ans = -1;
    for (i = 2;; i++) {
      j += i;
      if (j > n) break;
      m = n - j;
      if (m % i) continue;
      m /= i;
      k = m + 1;
      t = 0;
      for (; k <= m + i; k++) t = t ^ win[k];
      if (t == 0) {
        ans = i;
        break;
      }
    }
    printf("%d\n", ans);
    break;
  }
  return (EXIT_SUCCESS);
}
