#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
int g[MAXN + 5];
int n;
vector<pair<int, int> > v;
int f(int a, int b) {
  long long s1 = (long long)a * (a - 1) / 2;
  long long s2 = (long long)b * (b + 1) / 2;
  return s2 - s1;
}
bool cmp(pair<int, int> a, pair<int, int> b) {
  return f(a.first, a.second) != f(b.first, b.second)
             ? f(a.first, a.second) < f(b.first, b.second)
             : a.second - a.first < b.second - b.first;
}
int val(int a, int b) {
  int bm = 0;
  for (int i = (a), _for = (b + 1); i < _for; ++i) bm ^= g[i];
  return bm;
}
int main() {
  scanf("%d", &n);
  for (int i = (1), _for = (n + 1); i < _for; ++i)
    for (int j = i + 1; f(i, j) <= n; ++j) v.push_back(make_pair(i, j));
  sort(v.begin(), v.end(), cmp);
  int last = 0;
  int bm = 0;
  for (int i = (0), _for = (v.size()); i < _for; ++i) {
    int a = v[i].first, b = v[i].second;
    int s = f(a, b);
    if (s != last && last) {
      int first = 0;
      for (; bm & 1; bm /= 2, first++)
        ;
      g[last] = first;
      bm = 0;
    }
    last = s;
    bm |= (1 << val(a, b));
  }
  int first = 0;
  for (; bm & 1; bm /= 2, first++)
    ;
  g[last] = first;
  for (int i = (0), _for = (v.size()); i < _for; ++i) {
    int a = v[i].first, b = v[i].second;
    if (f(a, b) != n) continue;
    if (!val(a, b)) {
      printf("%d\n", b - a + 1);
      return 0;
    }
  }
  puts("-1");
  return 0;
}
