#include <bits/stdc++.h>
using namespace std;
int g[100010];
int main(void) {
  int A, T, N, M;
  scanf("%d", &N);
  for (int i = (int)(3); i <= (int)(N); i++) {
    set<int> st;
    A = 2000000000;
    for (int j = (int)(2); j <= (int)(N); j++) {
      int k = i - j * (j + 1) / 2;
      if (k < 0) break;
      if (k % j != 0) continue;
      int l = 1 + k / j, r = j + k / j, nim = 0;
      while (l <= r) {
        nim = nim ^ g[l++];
      }
      st.insert(nim);
      if (nim == 0) A = min(A, j);
    }
    int res = 0;
    while (st.find(res) != st.end()) res++;
    g[i] = res;
  }
  if (g[N])
    printf("%d\n", A);
  else
    printf("-1\n");
  return 0;
}
