#include <bits/stdc++.h>
using namespace std;
int g[100005];
int grundy(int x) {
  if (x == 0) return 0;
  int &ret = g[x];
  if (ret != -1) return ret;
  set<int> s;
  long long n;
  long long tmp;
  for (n = 2;; n++) {
    tmp = n * (n - 1) / 2;
    tmp = x - tmp;
    if (tmp <= 0) break;
    if (tmp % n == 0) {
      tmp /= n;
      int now = 0;
      for (int j = tmp; j < tmp + n; j++) {
        now ^= grundy(j);
      }
      s.insert(now);
    }
  }
  if (s.empty()) return ret = 0;
  set<int>::iterator it = s.begin();
  if (*it != 0) return ret = 0;
  int last = *it;
  for (it++; it != s.end(); it++) {
    if (*it - last > 1) return ret = last + 1;
    last = *it;
  }
  return ret = last + 1;
}
int main() {
  int sum, flag = 0;
  long long n, tmp;
  cin >> sum;
  memset(g, -1, sizeof(g));
  flag = 0;
  for (n = 2;; n++) {
    tmp = n * (n - 1) / 2;
    tmp = sum - tmp;
    if (tmp <= 0) break;
    if (tmp % n == 0) {
      tmp /= n;
      int now = 0;
      for (int j = tmp; j < tmp + n; j++) {
        now ^= grundy(j);
      }
      if (now == 0) {
        flag = 1;
        break;
      }
    }
  }
  if (flag)
    printf("%d\n", n);
  else
    puts("-1");
  return 0;
}
