#include <bits/stdc++.h>
using namespace std;
int g[100000];
int res[100000];
int main() {
  int N;
  scanf("%d", &N);
  ;
  g[0] = 0;
  g[1] = 0;
  res[0] = res[1] = -1;
  for (int(n) = 2; n < (int)N + 1; n++) {
    set<int> s;
    vector<int> v;
    for (int i = 2; i * i <= 2 * n; i++) {
      if ((2 * n) % i == 0) {
        v.push_back(i);
        v.push_back((2 * n) / i);
      }
    }
    res[n] = -1;
    for (__typeof(v).begin() it = v.begin(); it != v.end(); it++) {
      int help = 2 * n / (*it) + *it - 1;
      if (help % 2 == 0 && help / 2 >= *it && help / 2 < n) {
        int num = 0;
        for (int m = 0; m < *it; m++) {
          num = num ^ g[help / 2 - m];
        }
        if (num == 0) {
          res[n] = res[n] == -1 ? *it : min(res[n], *it);
        }
        s.insert(num);
      }
    }
    int sol = 0;
    while (s.find(sol) != s.end()) {
      sol++;
    }
    g[n] = sol;
  }
  if (g[N] == 0) {
    puts("-1");
  } else {
    printf("%d\n", res[N]);
  }
}
