#include <bits/stdc++.h>
using namespace std;
long long g[100002], xorr[100002];
priority_queue<pair<long long, pair<long long, long long>>,
               vector<pair<long long, pair<long long, long long>>>,
               greater<pair<long long, pair<long long, long long>>>>
    pq;
vector<long long> v;
signed main() {
  long long nn;
  cin >> nn;
  for (long long i = 1; i <= nn; i++) {
    if (2 * i + 1 <= nn) pq.push({2 * i + 1, {i, i + 1}});
  }
  g[1] = 0;
  g[2] = 0;
  xorr[0] = 0;
  xorr[1] = 0;
  xorr[2] = 0;
  long long ans = 1e18;
  for (long long i = 3; i <= nn; i++) {
    v.clear();
    while (1) {
      if (pq.empty()) break;
      auto zz = pq.top();
      if (zz.first > i) break;
      pq.pop();
      long long ddd = xorr[zz.second.second] ^ xorr[zz.second.first - 1];
      if (i == nn and ddd == 0)
        ans = min(ans, zz.second.second - zz.second.first + 1);
      v.push_back(ddd);
      if (zz.first + zz.second.second + 1 <= nn)
        pq.push({zz.first + zz.second.second + 1,
                 {zz.second.first, zz.second.second + 1}});
    }
    sort((v).begin(), (v).end());
    v.erase(unique((v).begin(), (v).end()), v.end());
    bool f = 0;
    for (long long j = 0; j <= ((int)((v).size())) - 1; j++)
      if (v[j] != j) {
        g[i] = j;
        xorr[i] = xorr[i - 1] ^ j;
        f = 1;
        break;
      }
    if (f) continue;
    g[i] = ((int)((v).size()));
    xorr[i] = xorr[i - 1] ^ g[i];
  }
  if (nn < 3 or g[nn] == 0) {
    cout << "-1";
    return 0;
  }
  cout << ans;
}
