#include <bits/stdc++.h>
using namespace std;
int dpacum[112345];
int dp[112345];
int f(int n);
int acum(int n);
int acum(int n) {
  if (n < 0) return 0;
  int &res = dpacum[n];
  if (res != -1) return res;
  if (n == 0) return res = 0;
  res = f(n) ^ acum(n - 1);
  return res;
}
int f(int n) {
  int &res = dp[n];
  if (res != -1) return res = 0;
  vector<int> v;
  for (int k = (2); k < (n); k++) {
    int sum = (k * (k - 1)) / 2;
    if (sum > n) break;
    if ((n - sum) % k == 0) {
      int a1 = (n - sum) / k;
      int ak = a1 + k - 1;
      v.push_back(acum(ak) ^ (acum(a1 - 1)));
    }
  }
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());
  res = ((int)((v).size()));
  for (int i = (0); i < (((int)((v).size()))); i++)
    if (v[i] != i) {
      res = i;
      break;
    }
  return res;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  memset(dp, -1, sizeof dp);
  memset(dpacum, -1, sizeof dpacum);
  if (f(n)) {
    for (int k = (2); k < (n); k++) {
      int sum = (k * (k - 1)) / 2;
      if (sum > n) break;
      if ((n - sum) % k == 0) {
        int a1 = (n - sum) / k;
        int ak = a1 + k - 1;
        if ((acum(ak) ^ (acum(a1 - 1))) == 0) {
          cout << k << endl;
          break;
        }
      }
    }
  } else
    cout << -1 << endl;
}
