#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > G[100005];
int dp[100005], Xor[100005];
int rec(int n) {
  int answer = 1e9;
  for (int i = 0; i < G[n].size(); i++) {
    int st = G[n][i].first;
    int ed = G[n][i].second + st - 1;
    int x = Xor[ed] ^ Xor[st - 1];
    if (x == 0) answer = min(answer, G[n][i].second);
  }
  return answer;
}
int main() {
  memset(dp, -1, sizeof(dp));
  for (int i = 1; i <= 100000; i++) {
    for (int j = i, sum = i; sum <= 100000; j++, sum += j) {
      if (j - i + 1 >= 2) G[sum].push_back(make_pair(i, j - i + 1));
    }
  }
  for (int n = 1; n <= 100000; n++) {
    set<int> ST;
    for (int i = 0; i < G[n].size(); i++) {
      int st = G[n][i].first;
      int ed = G[n][i].second + st - 1;
      int x = Xor[ed] ^ Xor[st - 1];
      ST.insert(x);
    }
    for (int i = 0;; i++) {
      if (ST.find(i) == ST.end()) {
        dp[n] = i;
        break;
      }
    }
    Xor[n] = Xor[n - 1] ^ dp[n];
  }
  int n;
  cin >> n;
  if (dp[n] == 0) {
    cout << -1 << endl;
    return 0;
  }
  cout << rec(n) << endl;
}
