#include <bits/stdc++.h>
using namespace std;
int grundy[100010];
int main() {
  grundy[0] = 0;
  for (int n = 1; n <= 100000; n++) {
    set<int> st;
    for (int k = 2; k * (k - 1) / 2 < n; k++) {
      if (2 * n % k != 0) continue;
      int a = n / k - (k - 1) / 2;
      if (n != a * k + k * (k - 1) / 2) continue;
      int s = 0;
      for (int j = 0; j < k; a++, j++) s ^= grundy[a];
      st.insert(s);
    }
    int x = 0;
    while (st.find(x) != st.end()) x++;
    grundy[n] = x;
  }
  int n;
  while (scanf("%d", &n) != EOF) {
    if (grundy[n] == 0)
      puts("-1");
    else {
      for (int k = 2; k * (k - 1) / 2 < n; k++) {
        if (2 * n % k != 0) continue;
        int a = n / k - (k - 1) / 2;
        if (n != a * k + k * (k - 1) / 2) continue;
        int s = 0;
        for (int j = 0; j < k; a++, j++) s ^= grundy[a];
        if (s == 0) {
          printf("%d\n", k);
          break;
        }
      }
    }
  }
  return 0;
}
