#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 1;
mt19937_64 rng(std::chrono::system_clock::now().time_since_epoch().count());
int ans[N], n;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    set<int> st;
    for (int j = 2; j * (j - 1) / 2 <= i; j++) {
      int rem = (i - j * (j - 1) / 2) % j;
      if (!rem) {
        rem = (i - j * (j - 1) / 2) / j;
        if (!rem) continue;
        if (rem) st.insert(ans[rem + j - 1] ^ ans[rem - 1]);
      }
    }
    while (st.find(ans[i]) != st.end()) ans[i]++;
    ans[i] ^= ans[i - 1];
  }
  for (int j = 2; j * (j - 1) / 2 <= n; j++) {
    int rem = (n - j * (j - 1) / 2) % j;
    if (rem) continue;
    rem = (n - j * (j - 1) / 2) / j;
    if (!rem) continue;
    if (!(ans[rem + j - 1] ^ ans[rem - 1])) return printf("%d\n", j), 0;
  }
  puts("-1");
}
