#include <bits/stdc++.h>
using namespace std;
const int SIZE = 100001;
int sg[SIZE];
int pre[SIZE];
int f[SIZE];
vector<pair<int, int>> pr[SIZE];
int r = 3;
int cal(int x, int y) {
  if (y <= r) {
    return (pre[x - 1] ^ pre[y]);
  } else {
    for (int i = r + 1; i <= y; i++) {
      pre[i] = pre[i - 1] ^ sg[i];
    }
    r = y;
    return (pre[x - 1] ^ pre[y]);
  }
}
int dfs(int x) {
  if (sg[x] != -1) {
    return sg[x];
  }
  int res = INT_MAX;
  vector<int> tmp;
  for (auto p : pr[x]) {
    int a0 = p.first, n = p.second;
    tmp.push_back(cal(a0, a0 + n - 1));
    if (tmp.back() == 0) {
      res = min(res, n);
    }
  }
  sort(tmp.begin(), tmp.end());
  tmp.erase(unique(tmp.begin(), tmp.end()), tmp.end());
  int cnt = 0;
  for (int i = 0; i < tmp.size(); i++) {
    if (cnt == tmp[i]) {
      cnt++;
    } else {
      break;
    }
  }
  f[x] = res;
  return sg[x] = cnt;
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  memset(sg, -1, sizeof(sg));
  sg[1] = 0;
  sg[2] = 0;
  sg[3] = 1;
  f[3] = 2;
  pre[3] = 1;
  for (int a0 = 1; a0 < SIZE / 2; a0++) {
    for (int n = 2;; n++) {
      int sum = (a0 + a0 + n - 1) * n / 2;
      if (sum >= SIZE) {
        break;
      }
      pr[sum].push_back({a0, n});
    }
  }
  for (int i = 1; i <= 100000; i++) {
    dfs(i);
  }
  int n;
  cin >> n;
  if (sg[n]) {
    cout << f[n];
  } else {
    cout << -1;
  }
  return 0;
}
