#include <bits/stdc++.h>
int resp[100100];
int us[20];
int main() {
  int n, i, j, k, cont, aux, sol;
  scanf("%d", &n);
  resp[0] = 0;
  resp[1] = 0;
  int ok = 1;
  for (i = 2; i <= n; i++) {
    cont = 2;
    aux = 3;
    memset(us, 0, sizeof(us));
    while (aux <= i) {
      if ((i - aux) % cont == 0) {
        k = -1;
        for (j = ((i - aux) / cont) + 1; j <= ((i - aux) / cont) + cont; j++) {
          if (resp[j]) {
            if (k == -1) {
              k = resp[j];
            } else {
              k ^= resp[j];
            }
          }
        }
        if (k == -1) k = 0;
        if (k == 0 && i == n && ok) {
          sol = cont;
          ok = 0;
        }
        us[k] = 1;
      }
      cont++;
      aux += cont;
    }
    k = 0;
    while (us[k]) k++;
    resp[i] = k;
  }
  if (resp[n])
    printf("%d\n", sol);
  else
    printf("-1\n");
}
