#include <bits/stdc++.h>
using namespace std;
const int MAX = 100010;
vector<pair<int, int> > V[MAX];
int dp[MAX];
int call(int num) {
  if (dp[num] != -1) return dp[num];
  set<int> S;
  for (pair<int, int> e : V[num]) {
    int cur = 0;
    for (int c = 1, d = e.second; c <= e.first; c++, d++) {
      cur ^= call(d);
    }
    S.insert(cur);
  }
  for (int i = 0;; i++) {
    if (S.find(i) == S.end()) return dp[num] = i;
  }
}
int main() {
  for (int i = 1; i <= 1e5; i++) {
    int sum = 0;
    for (int j = i;; j++) {
      sum += j;
      if (sum > 1e5) break;
      if (j - i + 1 > 1) V[sum].push_back({j - i + 1, i});
    }
  }
  for (int i = 1; i <= 1e5; i++) sort(V[i].begin(), V[i].end());
  memset(dp, -1, sizeof(dp));
  int n;
  scanf("%d", &n);
  if (!call(n))
    puts("-1");
  else {
    for (pair<int, int> e : V[n]) {
      int cur = 0;
      for (int c = 1, d = e.second; c <= e.first; c++, d++) {
        cur ^= call(d);
      }
      if (!cur) {
        cout << e.first << endl;
        return 0;
      }
    }
  }
  return 0;
}
