#include <bits/stdc++.h>
using namespace std;
int gnum[100010];
int cumilgnum[100010];
int main() {
  int N;
  cin >> N;
  vector<vector<pair<int, int> > > nos(N + 1);
  for (int i = 1; i <= N; i++) {
    int total = i;
    for (int j = i + 1; j <= N; j++) {
      total += j;
      if (total > N)
        break;
      else
        nos[total].push_back(make_pair(i, j));
    }
  }
  gnum[1] = gnum[0] = 0;
  for (int i = 2; i <= N; i++) {
    set<int> vals;
    for (int j = 0; j < nos[i].size(); j++) {
      int val = cumilgnum[nos[i][j].second] ^ cumilgnum[nos[i][j].first - 1];
      vals.insert(val);
    }
    int minVal = 0;
    auto it = vals.begin();
    while (it != vals.end() && (*it) == minVal) minVal++, it++;
    gnum[i] = minVal;
    cumilgnum[i] = cumilgnum[i - 1] ^ minVal;
  }
  if (gnum[N] == 0)
    cout << -1 << endl;
  else {
    int minLen = N + 1;
    for (int i = 0; i < nos[N].size(); i++) {
      int l = nos[N][i].first, r = nos[N][i].second;
      int gval = cumilgnum[r] ^ cumilgnum[l - 1];
      if (gval == 0 && r - l + 1 < minLen) minLen = r - l + 1;
    }
    cout << minLen << endl;
  }
  return 0;
}
