#include <bits/stdc++.h>
using namespace std;
map<int, int> c;
map<int, int> g;
int grandy(int n) {
  if (g.count(n)) return g[n];
  set<int> m;
  for (int a = 1; a <= n / 2; a++) {
    int k = 2;
    bool f = false;
    while (!f) {
      int s = (2 * a + k - 1) * k / 2;
      if (n == s) f = true;
      if (n <= s) break;
      k++;
    }
    if (f) {
      int g = 0;
      for (int j = a; j < a + k; j++) {
        g = g xor grandy(j);
      }
      if (g == 0) {
        if (c.count(n) == 0)
          c[n] = k;
        else
          c[n] = min(c[n], k);
      }
      m.insert(g);
    }
  }
  int r = 0;
  while (m.count(r)) r++;
  g[n] = r;
  return r;
}
int main(int argc, char* argv[]) {
  int n;
  cin >> n;
  grandy(n);
  if (c[n] > 0)
    cout << c[n] << endl;
  else
    cout << -1 << endl;
}
