#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 5;
long long n;
long long nim[N], prefnim[N];
vector<pair<long long, long long> > sum[N];
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    long long cur = i;
    for (long long j = i + 1; j <= n; j++) {
      cur += j;
      if (cur > n) break;
      sum[cur].push_back({i, j});
    }
  }
  for (long long i = 1; i <= n; i++) {
    unordered_set<long long> s;
    for (auto &it : sum[i])
      s.insert(prefnim[it.second] ^ prefnim[it.first - 1]);
    long long val = 0;
    while (s.find(val) != s.end()) val++;
    nim[i] = val;
    prefnim[i] = prefnim[i - 1] ^ nim[i];
  }
  if (nim[n] == 0)
    cout << "-1";
  else {
    long long ans = 1e9;
    for (auto &it : sum[n]) {
      if ((prefnim[it.second] ^ prefnim[it.first - 1]) == 0)
        ans = min(ans, it.second - it.first + 1);
    }
    cout << ans;
  }
  return 0;
}
