#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 7;
int dp[N], ans[N];
int cumxor[N];
int lo(int n, int k) {
  if (k % 2) {
    if (n % k) return 0;
    int ans = n / k - k / 2;
    if (ans <= 0) ans = 0;
    return ans;
  } else {
    if ((2 * n) % k) return 0;
    int mid = 2 * n / k;
    if (mid % 2 == 0) return 0;
    int ans = (mid - k + 1) / 2;
    if (ans <= 0) ans = 0;
    return ans;
  }
}
int mex(vector<int> vals) {
  sort(vals.begin(), vals.end());
  vals.erase(unique(vals.begin(), vals.end()), vals.end());
  for (int i = 0; i < vals.size(); i++)
    if (vals[i] != i) return i;
  return vals.size();
}
int main() {
  for (int i = 1; i < N; i++) {
    vector<int> vals;
    for (int k = 2; k * (k + 1) / 2 <= i; k++) {
      int l = lo(i, k);
      if (l == 0) continue;
      int r = l + k - 1;
      int xoor = cumxor[r] ^ cumxor[l - 1];
      if (xoor == 0 && !ans[i]) ans[i] = k;
      vals.push_back(xoor);
    }
    dp[i] = mex(vals);
    cumxor[i] = cumxor[i - 1] ^ dp[i];
    if (dp[i] == 0) ans[i] = -1;
  }
  int n;
  cin >> n;
  cout << ans[n];
}
