#include <bits/stdc++.h>
using namespace std;
int mex(vector<int> a) {
  sort(a.begin(), a.end());
  int ret = 0;
  for (int(i) = 0; (i) < (((int)a.size())); ++(i)) {
    if (ret == a[i]) ret++;
  }
  return ret;
}
int nimsum(vector<int> a) {
  for (int(i) = (1); (i) < (((int)a.size())); ++(i)) a[0] ^= a[i];
  return a[0];
}
int dp[120000];
int xorsum[120000];
vector<int> d[220000];
int main() {
  int n;
  cin >> n;
  for (int(i) = 0; (i) < (120000); ++(i)) dp[i] = -1;
  for (int(i) = (1); (i) < (200001); ++(i)) {
    int j = i;
    while (j < 200010) {
      d[j].push_back(i);
      j += i;
    }
  }
  dp[0] = 0;
  xorsum[0] = xorsum[1] = 0;
  for (int(i) = (1); (i) < (100001); ++(i)) {
    vector<int> divisors = d[i * 2];
    sort(divisors.begin(), divisors.end());
    reverse(divisors.begin(), divisors.end());
    vector<int> options;
    for (int(j) = 0; (j) < (((int)divisors.size())); ++(j)) {
      int num = divisors[j];
      int cnt = 0;
      int low = 0;
      if (num % 2 == 0) {
        num /= 2;
        cnt = i / num;
        if (cnt % 2 == 0) continue;
        low = num - cnt / 2;
      } else {
        cnt = (i * 2) / num;
        if (cnt % 2 == 1) continue;
        low = num / 2 - cnt / 2 + 1;
      }
      if (cnt == 1 || low <= 0) continue;
      int hi = low + cnt - 1;
      options.push_back(xorsum[hi + 1] ^ xorsum[low]);
      if (i == n && options.back() == 0) {
        cout << cnt << endl;
        return 0;
      }
    }
    dp[i] = mex(options);
    xorsum[i + 1] = xorsum[i] ^ dp[i];
    if (i == n) cout << -1 << endl;
  }
  return 0;
}
