#include <bits/stdc++.h>
using namespace std;
template <typename T, typename TT>
ostream& operator<<(ostream& s, pair<T, TT> t) {
  return s << "(" << t.first << "," << t.second << ")";
}
template <typename T>
ostream& operator<<(ostream& s, vector<T> t) {
  for (int i = 0; i < t.size(); i++) s << t[i] << " ";
  return s;
}
int g[100010], v[50], s[100010];
int main() {
  int m, i, j, T, k, n;
  g[0] = 0;
  s[0] = 0;
  for (i = 1; i < 100010; i++) {
    memset(v, 0, sizeof(v));
    for (k = 2;; k++) {
      int first = k * (k - 1) / 2;
      first = i - first;
      if (first < k) break;
      if (first % k) continue;
      int a = first / k, b = a + k - 1;
      first = s[b] ^ s[a - 1];
      v[first]++;
    }
    int first = 0;
    while (v[first]) first++;
    g[i] = first;
    s[i] = s[i - 1] ^ first;
  }
  while (~scanf("%d", &n)) {
    if (!g[n])
      puts("-1");
    else {
      for (k = 2;; k++) {
        int first = k * (k - 1) / 2;
        first = n - first;
        if (first < k) break;
        if (first % k) continue;
        int a = first / k, b = a + k - 1, d = s[b] ^ s[a - 1];
        if (d == 0) {
          printf("%d\n", k);
          return 0;
        }
      }
    }
  }
  return 0;
}
